Email APIs for developers

Send and receive emails and attachments programmatically. Use REST API or official SDK libraries to write applications and tests using real email addresses.

What to jump in? Checkout the API documentation or the getting started guide to see how it works.

MailSlurp was created as an email API that goes beyond traditional SMTP limitations.

MailSlurp is made for developers as an flexible MailServer with a REST API, a browser-based web-app, and programmatic SDKs built several languages. It is a hosted cloud service that is free for personal use.


A simple but powerful HTTP REST API plus official libraries in Javascript, Python, PHP, Java, Golang, Ruby, Objective C, and C# / DotNet.

MailSlurp has lots of [documentation], [example projects], and [guides] to help you and your team get started quickly with modern email APIs.

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 mailslurp = new MailSlurp({ apiKey });
const { id, emailAddress } = await mailslurp.createInbox();

Or with a custom email address:

// 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.

const timeout = 30_000;
// hold connection open until first email found or timeout
const { body, subject, attachments } = await mailslurp.waitForLatestEmail(,

// more examples
const nthEmail = await mailslurp.waitForNthEmail(!, 0, timeout);
const emailList = await mailslurp.waitForEmailCount(

Send emails and attachments

const [attachmentId] = await mailslurp.uploadAttachment({
  base64Contents: Buffer.from('test').toString('base64'),
  filename: 'test.txt',
  contentType: 'text/plain',
const sent = await mailslurp.sendEmail(!, {
  to: [inbox.emailAddress!],
  subject: emailSubject,
  attachments: [attachmentId.toString()],

Use pattern matching

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

// or wait for matching
const matchingEmails = await mailslurp.waitForMatchingEmails(
    conditions: [
        condition: ConditionOptionConditionEnum.HAS_ATTACHMENTS,
        value: ConditionOptionValueEnum.TRUE,
    matches: [
        field: MatchOptionFieldEnum.SUBJECT,
        should: MatchOptionShouldEnum.CONTAIN,
        value: emailSubject,
await mailslurp.deleteInbox(!);

Extract content and verify

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

const user = await myApp.signUp(testInbox.emailAddress!);

// verify that confirmation email was sent by your app
const timeout = 30000;
const email = await mailslurp.waitForLatestEmail(, timeout);

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

// 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 = await fs.promises.readFile(pathToAttachment, {
  encoding: 'utf-8',
const [id] = await mailslurp.uploadAttachment({
  base64Contents: file.toString('base64'),
  filename: 'attachment.txt',
  contentType: 'text/plain',

// attach the files with id to send
await mailslurp.sendEmail(!, {
  to: [recipientAddress],
  attachments: [id.toString()],

Scales with your business

MailSlurp is a cloud based distributed system that uses message queues to safely process messages.

WebHook queues

Please see the webhook usage guide for more information about webhooks.

Have received messages sent directly to your server in a queue system using webhooks. Backed by a powerful cloud queue MailSlurp will POST an email summary to your webhooks URL via HTTP whenever an email is received.

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

MailSlurp retries your webhook with a backoff for up to 24 hours and maintains a dead-letter queue.

Send templated emails

Send HTML emails with Handlebars templating support.

await mailslurp.sendEmail(!, {
  to: [recipientAddress!],
  subject: 'Hello {{name}}',
  body: 'Dear {{name}}, your code is {{code}}.',
  templateVariables: {
    name: 'John' as any,
    code: '123' as any,
const received = await mailslurp.waitForLatestEmail(,
expect(received.subject).toContain('Hello John');
expect(received.body).toContain('Dear John, your code is 123.');

Teams and admins

MailSlurp has pricing plans for enterprise usage and team access.

Manage your API usage and team access with our online dashboard or view the documentation to get started.