MailSlurp logo

Overview

Understand the MailSlurp docs surface, core platform pillars, and the fastest path into email, SMS, testing, monitoring, and automation.

View Markdown Agent setup

MailSlurp gives your team real inboxes, phone numbers, event hooks, testing tooling, monitoring, and governance controls in one platform. Use this page to choose the right docs path first, then jump into the workflow closest to your job.

Choose the docs path that matches your job

Start by team

Browse the platform by capability

Key docs in each pillar

Messaging

Testing and QA

Monitoring

  • Monitoring for the overall post-launch monitoring surface.
  • Domain Monitor for DNS posture and sender-health drift.
  • Campaign Probe for live campaign capture and review.
  • Reputation for bounce, complaint, and suppression-aware sender protection.

Automation

Team and governance

Developer tooling

How MailSlurp fits together

Most teams follow the same flow:

  1. Provision a fresh inbox, phone number, or mailbox connection.
  2. Run the workflow that should send or receive a real message.
  3. Inspect the message synchronously with wait methods or asynchronously with webhooks.
  4. Add monitoring, access controls, and environment separation as the workflow moves toward production.

Programmatic access

Get an SDK running

Start with an SDK setup snippet in your language. The same workflows are also available over the REST API.

Javascript

// create mailslurp client
const { MailSlurp } = require('mailslurp-client');
const mailslurp = new MailSlurp({ apiKey: process.env.API_KEY });

// create inboxes
const inbox1 = await mailslurp.createInbox();
const inbox2 = await mailslurp.createInbox();

// send email
await mailslurp.sendEmail(inbox1.id, {
  to: [inbox2.emailAddress],
  subject: "Test",
  body: "<span>Hello 👋",
  isHTML: true
})

// receive email using wait methods
const email = await mailslurp.waitForLatestEmail(inbox2.id, 60000, true)
expect(email.body).toContain("Hello")

// list emails in inbox
const emails = await mailslurp.inboxController.getInboxEmailsPaginated({inboxId: inbox2.id})
expect(emails.numberOfElements).toEqual(1)

C#

// create client
var config = new Configuration();
config.ApiKey.Add("x-api-key", ApiKey);

// create inboxes
var inboxControllerApi = new InboxControllerApi(config);
var inbox1 = inboxControllerApi.CreateInbox();
var inbox2 = inboxControllerApi.CreateInbox();

// send email
inboxControllerApi.SendEmail(inbox1.Id, new SendEmailOptions(
    to: new List<string> { inbox2.EmailAddress },
    subject: "Test CSharp",
    body: "<span>Hello",
    isHTML: true
));

// receive email with wait controller
var email = new WaitForControllerApi(config).WaitForLatestEmail(inbox2.Id, 60000, true);
StringAssert.Contains(email.Body, "Hello");

// list emails in inbox
var emails = inboxControllerApi.GetInboxEmailsPaginated(inbox2.Id);
Assert.AreEqual(emails.TotalElements, 1);

Go

// create a context with your api key
ctx := context.WithValue(context.Background(), mailslurp.ContextAPIKey, mailslurp.APIKey{Key: apiKey})

// create mailslurp client
client := mailslurp.NewAPIClient(mailslurp.NewConfiguration())

// create inboxes
inbox1, _, err := client.InboxControllerApi.CreateInbox(ctx, &mailslurp.CreateInboxOpts{})
inbox2, _, err := client.InboxControllerApi.CreateInbox(ctx, &mailslurp.CreateInboxOpts{})
assert.Nil(t, err)

// send email from inbox 1 to inbox 2
_, err = client.InboxControllerApi.SendEmail(ctx, inbox1.Id, mailslurp.SendEmailOptions{
	To:      []string{inbox2.EmailAddress},
	Subject: "Test",
	Body:    "<span>Hello",
	IsHTML:  true,
})
assert.Nil(t, err)

// now receive the email at inbox 2
email, _, err := client.WaitForControllerApi.WaitForLatestEmail(ctx, &mailslurp.WaitForLatestEmailOpts{
	InboxId:    optional.NewInterface(inbox2.Id),
	Timeout:    optional.NewInt64(60000),
	UnreadOnly: optional.NewBool(true),
})
assert.Nil(t, err)
assert.Contains(t, email.Body, "Hello")

// list emails
emails, _, err := client.InboxControllerApi.GetInboxEmailsPaginated(ctx, inbox2.Id, nil)
assert.Nil(t, err)
assert.Equal(t, emails.TotalElements, int64(1))

Java

// create client
ApiClient client = Configuration.getDefaultApiClient();
client.setApiKey(apiKey);
client.setHttpClient(httpClient);

// create inboxes
InboxControllerApi inboxControllerApi = new InboxControllerApi(client);
InboxDto inbox1 = inboxControllerApi.createInboxWithDefaults().execute();
InboxDto inbox2 = inboxControllerApi.createInboxWithDefaults().execute();

// send email
SendEmailOptions sendOptions = new SendEmailOptions();
sendOptions.setTo(Collections.singletonList(inbox2.getEmailAddress()));
sendOptions.setSubject("Test");
sendOptions.setBody("<span>Hello");
sendOptions.setIsHTML(true);
inboxControllerApi.sendEmail(inbox1.getId(), sendOptions);

// receive email with wait for controller
Email email = new WaitForControllerApi(client).waitForLatestEmail().inboxId(inbox2.getId()).timeout(60000L).unreadOnly(true).execute();
assertEquals(email.getBody().contains("Hello"), true);

// list emails in inbox
PageEmailPreview emails = inboxControllerApi.getInboxEmailsPaginated(inbox2.getId()).execute();

PHP

// configure client with api key
$config = MailSlurp\Configuration::getDefaultConfiguration()
    ->setApiKey('x-api-key', getenv('API_KEY'));

// create an inbox controller with config
$inboxController = new MailSlurp\Apis\InboxControllerApi(null, $config);

// create inboxes
$inbox1 = $inboxController->createInbox();
$inbox2 = $inboxController->createInbox();

// send an email
$inboxController->sendEmail($inbox1->getId(), new \MailSlurp\Models\SendEmailOptions(array(
    'to' => array($inbox2->getEmailAddress()),
    'subject' => 'Test email',
    'body' => '<span>Hello 👋',
    'is_html' => true
)));

// wait for email
$waitForController = new MailSlurp\Apis\WaitForControllerApi(null, $config);
$email = $waitForController->waitForLatestEmail($inbox2->getId(), 60_000, true);
PHPUnit\Framework\Assert::assertStringContainsString("Hello", $email->getBody());

// list emails in inbox
$emails = $inboxController->getInboxEmailsPaginated($inbox2->getId());
PHPUnit\Framework\Assert::assertEquals(1, $emails->getTotalElements());

Python

import mailslurp_client
# create a mailslurp configuration
configuration = mailslurp_client.Configuration()
configuration.api_key['x-api-key'] = api_key
with mailslurp_client.ApiClient(configuration) as api_client:
    # create an inbox
    inbox_controller = mailslurp_client.InboxControllerApi(api_client)
    inbox_1 = inbox_controller.create_inbox()
    inbox_2 = inbox_controller.create_inbox()

    # send email
    opts = mailslurp_client.SendEmailOptions()
    opts.to = [inbox_2.email_address]
    opts.subject = "Hello"
    opts.body = "Email content <strong>supports HTML</strong>"
    opts.is_html = True
    inbox_controller.send_email(inbox_1.id, send_email_options=opts)

    # receive email with wait controller
    wait_controller = mailslurp_client.WaitForControllerApi(api_client)
    email = wait_controller.wait_for_latest_email(inbox_id=inbox_2.id, timeout=60000, unread_only=True)

    # assert that the message was received
    assert email.inbox_id == inbox_2.id
    assert email.subject == "Hello"
    assert "Email content" in email.body

    # list emails in inbox
    emails = inbox_controller.get_inbox_emails_paginated(inbox_2.id)
    assert len(emails.content) >= 1

Ruby

# configure mailslurp client
MailSlurpClient.configure do |config|
  config.api_key['x-api-key'] = API_KEY
end

# create inboxes
inbox_controller = MailSlurpClient::InboxControllerApi.new
inbox_1 = inbox_controller.create_inbox
inbox_2 = inbox_controller.create_inbox

# send an email
inbox_controller.send_email(inbox_1.id,{
  to: [inbox_2.email_address],
  subject: 'Test',
  isHTML: true,
  body: '<h1>Hello!</h1>'
})

# receive email with wait controller
wait_controller = MailSlurpClient::WaitForControllerApi.new
email = wait_controller.wait_for_latest_email({ inbox_id: inbox_2.id, timeout: 60000 })
expect(email.body).to include("Hello")

# list inbox emails
emails = inbox_controller.get_emails(inbox_2.id)
expect(emails.length).to be(1)

Representative code samples

Examples below use JavaScript because the snippets are shortest there. The same flows exist across the SDKs and direct HTTP API.

Create an inbox

// create an inbox
const inbox = await mailslurp.inboxController.createInboxWithDefaults();
expect(inbox.emailAddress).toMatch(/.+@.+/);

Wait for a real email

// send an email
await mailslurp.inboxController.sendEmailAndConfirm({
    inboxId: inbox.id,
    sendEmailOptions: {
        to: [inbox.emailAddress],
        subject: "First email",
    }
})
// wait for the first unread email to arrive
const email = await mailslurp.waitController.waitForLatestEmail({
    timeout: 120_000,
    inboxId: inbox.id,
    unreadOnly: true
})
expect(email.subject).toContain('First email')

Push events to your server

const inbox = await mailslurp.createInbox();
const webhook = await mailslurp.webhookController.createWebhook({
  inboxId: inbox.id!,
  createWebhookOptions: {
    eventName: CreateWebhookOptionsEventNameEnum.NEW_EMAIL,
    url: testEndpoint.url!!,
  },
});

Add SMS coverage

const phone = await mailslurp.phoneController.createPhoneNumber({
  createPhoneNumberOptions: {
    name: 'Sales inbound',
    phoneCountry: CreatePhoneNumberOptionsPhoneCountryEnum.US,
  }
})
expect(phone.phoneNumber).toContain('+1')