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.
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.
Setup API access
You can call the MailSlurp email API using the REST API or one of the many official SDK libraries.
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:
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
cy.mailslurp()
// 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 => {
cy.get("[name=code]").type(code).trigger('change');
cy.get("[data-test=confirm-sign-up-confirm-button]").click();
})
});