Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Send & Receive Aliased Email Messages

Email Alias addresses automatically route email messages to and from the user's real email address they have chosen to associate with the alias via the verification process.

The handling of email messages being routed via an Email Alias is different depending on where the users real email address is hosted, those are:

  • Internal Email Alias: Where the real address is another Sudo Platform owned Email Address hosted in your Sudo Platform deployment.

  • External Email Aliases: Where the real address is an externally hosted email account.

Internal Email Aliases

An Internal Email Alias allows the user to freely send and receive messages via their Alias, without exposing their real email address to other participants in the email chain.

Inbound Message Receiving

When the Sudo Platform Email Service receives an email message to an Internal Email Alias it is processed in almost an identical manner as emails sent directly to an Email Address. It will be placed in the INBOX of the Email Address and can be distinguished from other messages by the presence of the emailAliasId property on the emailMessage object. These messages can be retrieved the same way as any other message as described in Receiving Email Messages

Outbound Message Sending

Users can send messages directly using their Internal Email Alias. To do this, invoke the sendEmailMessageViaAlias method. This works in much the same way as usual, including with the ability to send end-to-end encrypted messages where possible. See Send & Receive Email Messages for more detail

// Collect the input headers, body, attachments and sender email alias id 
// however makes sense for your implementation.
const senderEmailAliasId: string = emailAlias.id 
const emailMessageHeader: InternetMessageFormatHeader = {
    from: { emailAddress: "from@bar.com" }, // Must match emailAlias.aliasAddress
    to: [{ emailAddress: "to@bar.com" }],
    cc: [{ emailAddress: "cc@bar.com" }],
    bcc: [{ emailAddress: "bcc@bar.com" }],
    replyTo: [{ emailAddress: "replyTo@bar.com" }],
    subject: "Example subject line",
}
const emailAttachment: EmailAttachment = {
    filename: "fooAttachment.pdf",
    contentId: uuid.v4(),
    mimeType: "application/pdf",
    inlineAttachment: false,
    data: // ... Some pdf data
}
const inlineAttachment: EmailAttachment = {
    filename: "fooImage.png",
    contentId: uuid.v4(),
    mimeType: "image/png",
    inlineAttachment: true,
    data: // ... Some image data
}
try {
    const input: SendEmailMessageViaAliasInput = {
        senderEmailAliasId: senderEmailAliasId,
        emailMessageHeaders: emailMessageHeader,
        body: "An example email body",
        attachments: [emailAttachment],
        inlineAttachments: [inlineAttachment],
    }
    const result = await emailClient.sendEmailMessageViaAlias(input)
    // `result` contains the identifier and created timestamp associated with the sent email message. You can use this to access the data of the email message.
} catch {
    // Handle/notify user of error 
}

External Email Aliases

An External Email Alias handles messages significantly differently to Internal Email Aliases. The Sudo Platform Email Service does not store a copy of the body or other headers of messages it receives for External Email Aliases. Instead, it adjusts the headers then forwards the message to the user's real email address. There are no methods in the Sudo Email SDK associated with sending or receiving messages associated with an External Email Alias.

Inbound Message Receiving

The Sudo Platform Email Service must make some changes to the headers of an email before forwarding it to the user's real email address.

For the following example, assume the following:

  • The domain set up for Email Aliases in the Sudo Platform is alias.sudoplatform.com

  • Email Alias

    • Alias address: superman@alias.sudoplatform.com

    • External email address: clark.kent@example.com

  • Sender's address: lex.luthor@example.com

When a message is received that has been sent to superman@alias.sudoplatform.com from lex.luthor@example.com, the Sudo Platform Email Service makes the following changes to the message headers before forwarding the message to clark.kent@example.com:

  • The From header is changed to "lex.luthor@example.com via" <superman@alias.sudoplatform.com>

  • The To header (or Cc if that was used) is changed to clark.kent@example.com

  • The Reply-To header is changed to replies@alias.sudoplatform.com

The service will then forward the message to clark.kent@example.com and store the message identifier along with the emailAliasId and the sender's address securely in order to allow for future replies to be handled.

Outbound Message Sending

A user can reply to messages received via their External Email Alias from their preferred email client, by the standard email reply flow. The message will be sent to replies@alias.sudoplatform.com , processed by the Sudo Platform Email Service, and forwarded to the original sender.

Important: A user cannot initiate an email chain via an External Email Alias. They can only reply to messages they have already received. That is, there is no way for superman@alias.sudoplatform.com to send an email to lois.lane@example.com except as a reply to an email from lois.lane@example.com.

Continuing with the above example, when a message is received that has been sent to replies@alias.sudoplatform.com, from clark.kent@example.com, the Sudo Platform Email Service will read the In-Reply-To header of the message to get the id of the original message and attempt to retrieve the record associated with it. If it is available, it will look up the Email Alias associated with the emailAliasId and the original sender's email address. It will then make the following changes to the message headers:

  • The From header is changed to superman@alias.sudoplatform.com

  • The To header is changed to lex.luthor@example.com

The service will also make an effort to remove any other headers that may contain clark.kent@example.com . The message is then forwarded to lex.luthor@example.com .

Last updated