Email API custom domain

Set up your custom email domain with MailSlurp and access it programmatically in your code. Learn how to do it with our hosted email domains.

  • Table of contents

email custom domain hosted

If you have a custom email address that matches your companies domain you may wish to use it programmatically in code or tests. With MailSlurp you can keep access to your custom email address and also access it in scripts and code.

Custom domain setup

First register a free account with MailSlurp. Add your domain and follow the steps to verify your domain.

create domain

Setup API access

You can call the MailSlurp email API using the REST API or one of the many official SDK libraries.

api key

Configure your client with the API Key or set the REST header x-api-key to your value.

Example code

MailSlurp supports many languages and also has a web app you can use instead:

email apis

Here is a Javascript example using Cypress JS to receive emails.

it("03 - can receive confirmation code by email", function () {
    // app will send user an email containing a code, use mailslurp to wait for the latest email
        // use inbox id and a timeout of 30 seconds
        .then(mailslurp => mailslurp.waitForLatestEmail(this.inboxId, 30000, true))
        // extract the confirmation code from the email body
        .then(email => /.*verification code is (\d{6}).*/.exec(email.body!!)!![1])
        // fill out the confirmation form and submit
        .then(code => {
Email and SMS Platform
Create a free account in 3 clicks