What is transaction email (and how to send it)

Tutorial on how to send emails in response to events

receive real emails

What is a transactional email?

Transactional emails are emails that are sent on behalf of an application as a result of a particular user event. Typically this can mean email verification messages, newsletters, invoices, and much more.

Triggering emails

Many applications have logic that handles user actions that should result in an email being sent. They then create an email and send it via SMTP or an email sending service.

Email sending services

Sending emails via application code is actually a bit more complicated than it seems. You need to provision an SMTP server, propagate the correct DNS records and then securely communicate with said server from application code.

It is far simpler to simply outsource the SMTP aspect of email and use a transactional email service.

Sending via API or SDK

Most email sending services offer REST APIs or SDK client libraries to send emails from your codebase.

Test email accounts

To test that transactional emails are really being sent by your application you need an email address to send them to. You could use your own but this doesn’t scale and can’t easily be automated.

With email testing services like MailSlurp you can create unlimited fake test email accounts and use them in tests to verify that your app sends transactional emails correctly.