Email Aliases

Email aliases let you hide an email address behind any number of generated email addresses that will forward their incoming messages to the hidden email address.

More information can be found on the alias product page.

What is an alias

An alias is an email address that can be used to mask another email address. When the alias receives an email it will be forwarded automatically to the email address it was created for.

Properties

An alias object looks like so:

export interface AliasDto {
    createdAt?: Date;
    emailAddress?: string;
    id: string;
    inboxId?: string;
    isVerified?: boolean;
    maskedEmailAddress?: string;
    name?: string;
    updatedAt?: Date;
    useThreads?: boolean;
    userId: string;
}

You can manage aliases using the API, SDKs, or the dashboard.

create alias

Verification

You must manually verify an alias before it is active if the email address has not been validated for your account before.

create alias

Code example

Here is an example of how to use aliases using the official Javascript SDK and Jest.

/**
 * Example of using an email alias to mask an address and forward emails to hidden address
 */
const fetchApi = require('isomorphic-fetch');
const {
  AliasControllerApi,
  InboxControllerApi,
  Configuration,
  WaitForControllerApi,
} = require('mailslurp-client');

// setup mailslurp config
const config = new Configuration({ apiKey, fetchApi });

// create controllers
const inboxControllerApi = new InboxControllerApi(config);
const aliasControllerApi = new AliasControllerApi(config);
const waitForController = new WaitForControllerApi(config);

// create two different email addresses for testing
const inboxA = await inboxControllerApi.createInbox({ name: 'inboxA' });
const inboxB = await inboxControllerApi.createInbox({ name: 'inboxB' });
const emailAddressA = inboxA.emailAddress!!;
const emailAddressB = inboxB.emailAddress!!;

// create an alias
const alias = await aliasControllerApi.createAlias({
  createAliasOptions: {
    emailAddress: emailAddressA,
    useThreads: true,
  },
});
// emailAddressA has been masked by a new email address that was created by the alias
expect(alias.maskedEmailAddress).toEqual(emailAddressA);
expect(alias.emailAddress).not.toEqual(emailAddressA);

// alias isn't verified until you click the confirmation link sent to the aliased address
expect(alias.isVerified).toEqual(true);

Next steps

For information see the developers page.