How app emails work
Two kinds of email
| TransactionalTransactional emailAn email sent because of something the user did or something that happened to their account, like a receipt or a password reset.Open in glossary → | Marketing | |
|---|---|---|
| Sent because | The user did something, or something happened to their account | The company wants to promote something |
| Examples | Order confirmation, password reset, receipt, “new login from Chrome”, delivery update | Weekly deals, newsletter, “We miss you” |
| User consent | Not needed; it’s part of the service | Needed (in the EU and many other countries, before the first email). Everywhere, the user must be able to opt out at any time |
| Unsubscribe link | Usually not, or only for optional types | Required in every email |
| Timing | Immediately, or at an exact moment | Campaigns, often in batches |
Mixing them up causes bugs in both directions: an unsubscribe that also stops receipts and password links, or deals sent to a user who opted out.
From event to inbox
- An event happens: an order is placed, a password reset is requested, a courier picks up a delivery.
- The server picks a template (email templateEmail templateThe reusable layout and text of an email, with placeholders that are filled with each user's data.Open in glossary →): a ready-made email with placeholders like
{{first_name}}. The server fills them with data: name, items, totals, links. - The email goes to a queue, where it waits its turn, and then to an email service provider: a company that sends email for other companies, such as SendGrid, Postmark, Mailgun or Amazon SES.
- The provider delivers it, and the receiving mail server decides: inbox, spam or rejected.
- The user’s email app shows it, and each app (Gmail, Outlook, Apple Mail) renders it a little differently.
Each step can fail on its own. A wrong event, wrong data, a stuck queue, a spam folder or a broken layout all look the same to the user: “I didn’t get a proper email.”
Never email real people from a test environment
Test environmentsEnvironmentA setup of servers, data and configuration where the software runs, such as dev, staging or production.Open in glossary → often contain copies of real data. If stagingStagingA pre-release environment that mirrors production as closely as possible.Open in glossary → sends emails, real customers can get test receipts. Teams prevent this with:
- A test inboxTest inboxA fake mail server for test environments that catches every email the app sends, so none reach real people.Open in glossary →: a fake mail server that catches every email, such as Mailpit on a developer’s computer or Mailtrap in the cloud. Nothing leaves it.
- An allowlist: a list of approved recipients. Staging only sends to the team’s own addresses (for example everything ending in
@freshcart.com) and drops the rest. - Plus addresses (plus addressingPlus addressingAdding +something before the @ in an email address, like anna+shop@mail.com. Mail still reaches anna@mail.com.Open in glossary →) like
anna+fc1@example.com, which most mail services deliver toanna@example.com. One real inbox, many test accounts. This only helps together with one of the first two: it gives you many addresses, it doesn’t stop emails to real customers.
Ask which one your team uses before you trigger your first email.
Check this part
Which email must always have an unsubscribe link?
Why do teams use a test inbox or an allowlist on staging?