Managing Email Masks

The essentials to give your users the ability to secure their real email addresses behind Email Masks

Email Masks can be provisioned for different configured domains to provide more options to your users.

To provision an Email Mask, first check if it is valid and available. Once the address is chosen and confirmed, it can be used to provision the Email Mask.

Get Email Mask Domains

Before checking for the availability of an address for an Email Mask for your user, a valid mask domain is needed. The Sudo Platform Email Service can be configured to support multiple domains for this purpose.

circle-info

Each project in your Sudo Platform account can be configured to support a set of email domains. Your solutions engineer can assist you in configuring DNS entries for domains you own or you can have the Sudo Platform do that on your behalf.

A call to the getEmailMaskDomains method provides a list of domains that are available for provisioning Email Masks.

try {
    const maskDomains = await emailClient.getEmailMaskDomains()
    // `maskDomains` contains an array of supported domains to be used for provisioning Email Masks
} catch (e) {
    // Handle/notify user of errors
}

Check Email Mask Availability

In order to ensure your users can choose a unique, available, address for their Email Mask, you can use the same checkEmailAddressAvailability method as you would for a regular Sudo Platform email address. More information on that method can be found herearrow-up-right.

Provision Email Mask

Once your user has the address they would like to use for their Email Mask, it can be provisioned. The provisionEmailMask method will return the newly provisioned Email Mask object.

An ownershipProofToken is required as part of the input. This ties together the Sudo and Email Mask such that the Sudo becomes the owner of the Mask. Use the getOwnershipProof method on the SudoProfilesClient in the Sudo Profiles SDK in order to obtain an ownershipProofToken. See the Sudoarrow-up-right section for more information.

Real Address Ownership

The realAddress property of the input must be the exact local-part@domain email address that the mask should forward to. For Sudo Platform Email Addresses, the address must be owned by the same user trying to provision the Mask.

If, however, you decide to enable the option to allow your users to set up Masks for external email addresses, then the Mask that gets provisioned will initially have its state set to PENDING. While in this state, it cannot receive messages. In order to change the state to ENABLED, the user must verify ownership of their external email address. See Verifying External Email Addresses.

Entitlements

In order to be able to provision an Email Mask, the user must be entitled. The following entitlement checks are performed:

  1. The user is entitled to provision Email Masks by the sudoplatform.email.emailMaskUserEntitled entitlement.

  2. The user against which the new email address is to be provisioned has at least 1 remaining sudoplatform.email.emailMaskMaxPerUser entitlement to consume.

If these entitlements' checks do not succeed, the provisionEmailMask API fails with an insufficient entitlements error.

circle-info

See Email Entitlementsarrow-up-right for an overview of how the Email service integrates with the Sudo Platform Entitlements system.

Optional Parameters

The provisionEmailMask method's input object can take up to two additional optional parameters:

  1. expiresAt - If set, the mask will automatically be deprovisioned at the given date.

  2. metadata - This is a string to string map that can be used to store information about the Email Mask such as the purpose of it. The data in this property gets encrypted with the user's default key pair before being sent to the server, and decrypted upon retrieval.

Both of these optional properties can be updated, or deleted via the updateEmailMask method.

Deprovision Email Mask

An Email Mask can be deprovisioned using the deprovisionEmailMask method by passing in the id of an existing Email Mask object.

circle-exclamation

Updating an Email Mask

An existing email mask can have a subset of its data updated by the user by calling the updateEmailMask method. The properties that can be updated are outlined in the table below.

Property
To ignore
To delete

expiresAt

TypeScript: undefined (or exclude from object) Swift: nil Kotlin: null

Typescript: null Swift: Date(timeIntervalSince1970: 0) Kotlin: Date(0)

metadata

TypeScript: undefined (or exclude from object) Swift: nil Kotlin: null

Typescript: null Swift: [:] Kotlin: emptyMap()

Retrieving Existing Email Masks

Previously provisioned Email Masks can be retrieved as a paginated list via the listEmailMasksForOwner method.

A call to the API will return a ListOutput<EmailMask> object. The items property will contain a list of the masks and the nextToken property will contain a token that can be used for retrieving the next page of results if there are more.

The list can also be filtered by passing in an optional filter property to the method call. The call can be filtered by status and/or realAddressType. Each of those must further be specified as either equal, oneOf, notEqual or notOneOf.

The list can also be given a limit on how many results to return. By default, this limit is 10.

Disabling and Enabling Email Masks

An Email Mask can be disabled by the user to temporarily stop it from receiving emails without fully deprovisioning it. When in the DISABLED status, messages sent to the mask will not be delivered to the real address, and the sender will not receive a bounce in response until it is enabled again.

Last updated