Managing Email Masks
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 the sequence is:
Retrieve the list of available domains
Check if the desired mask address for a given domain is valid and available
Provision the Email Mask address
Get Email Mask Domains
The Sudo Platform Email Service can be configured to support multiple domains for your email masking needs.
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
}do {
let maskDomains = try await client.getEmailMaskDomains()
// `maskDomains` contains alist of domains available for provisioning Email Masks
catch {
/// Handle/notify user of errors
}launch {
try {
val maskDomains = withContext(Dispatchers.IO) {
emailClient.getEmailMaskDomains()
}
// [maskDomains] contains a list of configured domains for provisioning Email Masks.
} catch (e: EmailAddressException) {
// Handle/notify user of exception
}
}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 here.
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 Sudo section for more information.
Verify 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 your use case requires to allow your users to set up Masks for external email addresses, then the Mask that is 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:
The user is entitled to provision Email Masks by the
sudoplatform.email.emailMaskUserEntitledentitlement.The user against which the new email address is to be provisioned has at least 1 remaining
sudoplatform.email.emailMaskMaxPerUserentitlement to consume.
If these entitlements' checks do not succeed, the provisionEmailMask API fails with an insufficient entitlements error.
Optional Parameters
The provisionEmailMask method's input object can take up to two additional optional parameters:
expiresAt- If set, the mask will automatically be deprovisioned at the given date.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.
By deprovisioning an Email Mask, the user will no longer receive messages sent to that Mask, and a bounce will be returned to anyone sending messages to it.
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.
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. While in the DISABLED state, 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