Course B · Module B1 Production · Lesson 7 of 18
Make your app send the right email at the right moment, on its own — without you lifting a finger.
Every production app sends emails: a receipt after purchase, a password-reset link, a notification when something important happens. Done manually, these eat hours. Done wrong, they land in spam. Done right, they run invisibly in the background and make your product feel polished. Your single win: by the end you'll know the difference between the two kinds of email, understand why Gmail won't cut it, and be ready to wire an email API into your app in an afternoon.
Triggered by something the user did. Order confirmation, password reset, welcome on sign-up, payment receipt, "your file is ready" notification. The user expects it immediately. This is what you build with an email API.
You decide when it goes out — newsletters, promotions, drip sequences. The user may or may not want it. Requires an unsubscribe link by law in most countries. Use a dedicated tool (Mailchimp, Kit, Loops) — not the same API.
Mixing them up creates legal and deliverability problems. Keep them separate: email API for triggered messages your app sends, dedicated marketing tool for broadcasts you send.
Imagine you wanted to ship 500 packages a day. You could carry them in your car — technically possible, totally impractical, and the post office would flag you pretty fast. Gmail is your car. An email API is a courier company with a loading dock, a delivery guarantee, and a tracking number for every package.
The technical reality behind the analogy comes down to three things:
noreply@yourbusiness.com, not a personal Gmail. Email APIs let you send from your own domain once you verify it.Three providers are dominant for transactional email. All three have a free tier good enough to start with:
The integration pattern is the same as any API (B5): you get an API key from the provider's dashboard, store it in your environment variables (never hardcoded), and call the provider's library with the recipient, subject, and body. Your AI assistant can generate the full sending function from the provider's quickstart — just paste the URL and ask.
{{order_id}}, {{amount}}) at
send time. Your AI can generate both the template HTML and the code that fills it in.
This is far cleaner than building email HTML inside your application code.
Every transactional email follows the same shape: something happens in your app → your code calls the email API → user gets an email. The "something happens" is the trigger you learned about in Course A automations — a new user signs up, a payment succeeds, a file finishes processing. Map these out before you build:
Answer before opening — recalling it is what makes it stick.
Transactional. It was triggered by the user's action, expected immediately, and contains information they specifically requested. Build it with an email API like Resend or Postmark — not your marketing tool.
Gmail wasn't built for app-generated bulk sending. It lacks a warmed sending reputation for this use, and you're missing the SPF and DKIM DNS records that tell receiving servers your email is legitimate. Switch to a dedicated email API and verify your domain.
A template is pre-written email HTML with placeholders for dynamic values like names or order numbers. Your code just fills in the blanks at send time instead of building email HTML inline. This separates the email's design from your app logic and makes both easier to update.
Read this next (primary source)
Resend Documentation — the introduction and quickstart walk through domain verification, API key setup, and sending your first email in under ten minutes. Clear and non-technical enough to follow alongside your AI assistant. See RESOURCES.md for more.
New terms this lesson — transactional email, deliverability, SPF/DKIM, email template — are in the course glossary. Keep it open.