Using Email APIs to test your app


MailSlurp is an email API service for creating email addresses on demand from which you can send and receive email in code or online. It has a simple HTTP API plus official libraries in Javascript, Python, PHP, Java, Golang, Ruby, Objective C, and C# / DotNet.

Email addresses on demand

Create new private email addresses on demand from applications or tests. (Examples in Javascript but available in all languages.)

// create a randomly assigned email address
const inbox = await mailslurp.createInbox()

// create a custom email address with your own domain
const customInbox = await mailslurp.createInbox('')

Fetch emails in code

Receive emails directly in tests or applications.

// hold connection open until first email found or timeout
const email = await mailslurp.waitForLatestEmail(
console.log(email.subject, email.body, email.attachments)

// more examples
const nthEmail = await mailslurp.waitForNthEmail(, index)
const emails = await mailslurp.waitForEmailCountinbox(, count)

Use pattern matching

Search for emails matching field or body conditions. Use email with powerful helper functions.

// fetch in tests
const welcomeEmails = await mailslurp.waitForMatchingEmails({
matches: [
field: 'SUBJECT',
should: 'CONTAIN',
value: 'Welcome'
}, count,

Extract content and verify

You can use MailSlurp to extract email contents and attachments for use in tests or email processing pipelines.

const testInbox = await mailslurp.createInbox()
const user = await myApp.signUp(testInbox.emailAddress)

// verify that confirmation email was sent by your app
const email = await mailslurp.waitForLatestEmail(

// confirm the user using the code
const [_, verificationCode] = /your code is "([0-9]{6})"/g.exec(email.body)

// do something with code like verifying an account
await myApp.confirmUser(verificationCode)

Send email attachments

Easily send attachments and emails in code without SMTP setup.

// upload attachments to mailslurp
const file = fs.readFileSync(path);
const [id] = await mailslurp.uploadAttachment({
base64Contents: new Buffer(file).toString('base64'),
filename: '',
contentType: ''

// attach the files with id to send
mailslurp.sendEmail(, {
to: [''],
attachments: [id]

WebHook queues

Have received messages sent directly to your server in a queue system with webhooks.

// get messages sent to your server
fun receiveEmails(emailEvent: Map<String,String>) {
// respond to event

Send templated emails

Send HTML emails with Handlebars templating support.

mailslurp.sendEmail(, {
to: [''],
subject: 'Hello {{name}}',
body: 'Dear {{name}}, your code is {{code}}.',
templateVars: {
name: '',
code: ''

Convenient UI

Manage your API usage and team access with our online dashboard.

MailSlurp is free for personal use and scales with your team. Try it today.

Originally published at



Test Email API for end-to-end with real email addresses. Support for NodeJS, PHP, Python, Ruby, Java, C# and more. See for details.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
MailSlurp | Email APIs for developers

MailSlurp | Email APIs for developers

Test Email API for end-to-end with real email addresses. Support for NodeJS, PHP, Python, Ruby, Java, C# and more. See for details.