Using Email APIs to send and receive emails

Generate dynamic email addresses on demand with MailSlurp - a modern email API.

MailSlurp is a free email API for creating email accounts on demand that can send and receive real emails from code or tests.

What is an email API?

Many applications and businesses today depend on email. Email powers user sign-up, invoicing, payments, communication and more. Email has been around for a long time but the underlying SMTP technology hasn't changed much. That's why Email APIs are becoming increasingly popular with developers, QA testers, and content managers. Email APIs add modern features to email allowing us to go beyond email's original constraints.

What's wrong with SMTP

SMTP (Simple Mail Transfer Protocol) is simple: it's solid and reliable but not very flexible for modern use cases. Setting up multiple email addresses is time-consuming and confusing. Have you ever configured your domain provider with TXT and MX name records? What about spam rating and DKIM? Never heard of any of these terms? Don't worry, email APIs provide all the features of standard mail servers plus more (including disposable mailboxes).

What can email APIs do?

Email services like MailSlurp abstract SMTP into more approachable and extensible concepts.

API means "application programming interface": like a set of buttons on a machine that abstract complex tasks into a single click.

APIs like MailSlurp let users create email addresses instantly. APIs let developers send and receive emails from many different environments, like mobile applications, webservers, embedded devices and more.

What does an email API look like?

APIs usually resemble a collection of commands that a server or website can interpret. By sending commands to the server it will take action on behalf of the sender. For example here is how you would create an email address for testing in Javascript using MailSlurp:

const { id, emailAddress } = await mailslurp.createInbox();

What is the difference between SMTP and an email API

The main difference between SMTP and an email API is ease of use and what you can do with it. SMTP is traditionally complex to configure and most people use some tool like Gmail or Outlook to manage their accounts. These tools are great for casual use but for complex operations SMTP shows brittleness. Email APIs like MailSlurp are fast to establish and can scale with your needs - much faster than SMTP servers.

What are some use cases?

Thousands of developers use MailSlurp to generate test email accounts, receive emails in code, parse attachments and validate email content. The also use it to send templated HTML emails and attachments en-masse. Doing so in SMTP requires a lot of head scratching.

What are some examples?

Users of MailSlurp have used the email APIs to test user sign-up end-to-end. This means testing an application's account creation process in an automated way using real email addresses. Customers have found this to be a life-saving feature for production software: imagine knowing instantly if code changes have affected your user sign-up process.

// email apis can be used to extract email content
// like sign-up confirmation codes
const { body, subject } = await mailslurp.waitForLatestEmail(
  inbox.id,
  timeout
);

expect(body).toContain('123456');
const confirmationCode = body!.match(/([0-9]{6})/)![1]!;

Any more?

Other email API examples include testing transactional email content or automated messaging using temporary inboxes. Many applications today send emails in response to a user's actions. These emails should be tested automatically whenever code changes in order to confirm their validity. With MailSlurp you can create email addresses dynamically, send emails to them from your application, and then validate them from within tests or view their content in a visual dashboard.

How do I get started?

Get started for free today at app.mailslurp.com.

Related content

Using Email APIs to send and receive emails

Generate dynamic email addresses on demand with MailSlurp - a modern email API.

How to test an email address

Test email accounts for testing email addresses in code or online. Create fake email accounts for testing.

Codeception PHP acceptance testing using real email address APIs

Write acceptance tests in PHP with real email addresses using Codeception and MailSlurp

Java, Selenium

Receive emails in Java test suites using MailSlurp, Junit, and Selenium.

Python Robot Framework email test

Python automation email testing Robotframework plugin

Specflow user sign-up testing with MailSlurp accounts

How to test .NET authentication and sign-up using real email accounts with MailSlurp and SpecFlow.

Cucumber, Ruby

Generate test email accounts with Ruby and Cucumber. Test email sign-up, password verification and more.

TestCafe end-to-end MFA testing for user sign-up and email verification

End-to-end testing with MailSlurp, NodeJS, and TestCafe.

Test email address

Free test email address for testing emails online with web dashboard or REST API.

Testing guide

Integration testing with disposable email accounts using CypressJS, Selenium and many other frameworks. Test OTP password login, transactional emails, notifications and more.

Ready to dive in?Start building email applications today.