Email trapping with MailSlurp

Testing email without really sending using virtual mailboxes

If you send emails on behalf of your business or create programs that rely on email sending then you should probably use a virtual email mailtrap to test email sending end-to-end. Mailtraps are a way to capture outbound emails before they are sent and review email contents.

Mailtrap services

There are several free API services for testing SMTP email mail servers. Using mailtraps we can use fake SMTP mail server credentials in applications and tests and restrict sending so that emails are not really sent.

Why test emails?

Testing applications and code using real emails is the best way to verify product functionality. To avoid sending dummy emails to real customers most developers use a mailtrap like MailSlurp to create dummy test email addresses that can receive emails but will not send any emails to existing addresses.

How to create test mailservers

Mailserver inboxes can be created on demand using services such as MailSlurp. Typically a tester or developer will create a new mailbox during each test run or integration test.

const inbox = await mailslurp.inboxController.createInbox({});
expect(inbox.emailAddress).toContain('@mailslurp');

Inboxes can be created with a virtual flag so they act as a mail trap that traps outbound emails before they are sent.

Ready to dive in?Start building email applications today.