Tutorials / Backend integrations / Send transactional email with SendGrid
📝 Written ● Beginner Updated 2026-05-13

Send transactional email with SendGrid

SendGrid is the largest email API by volume — Twilio-owned, used by Uber, Airbnb, Spotify. Designed for scale: sub-accounts, dedicated IPs, IP warmup, marketing + transactional in one product. The trade-off is heavier UI and pricier mid-volume tiers.

When to pick SendGrid

0
  • Pick SendGrid when — you're at enterprise volume (1M+ emails/month), need sub-accounts for multiple brands/teams, want both transactional + marketing in one tool, or need dedicated IPs.
  • Pick Resend for dev-first DX at small/medium scale.
  • Pick Postmark for best inbox placement at small/medium scale.
  • Pick AWS SES for the cheapest per-email at any scale, if you're OK doing more setup yourself.

Sign up

1

Sign up at signup.sendgrid.com ↗. The free tier is 100 emails/day forever after the 60-day trial; paid plans start at $19.95/mo for 50K emails.

SendGrid's signup process includes account verification — they sometimes ask follow-up questions for new accounts to fight abuse. Be patient.

Verify your sender

2

Two options:

  • Single Sender Verification — verify one email address. SendGrid emails a confirmation link. Easiest for getting started, but limits deliverability. Docs ↗.
  • Domain Authentication — verify an entire domain via DNS. Recommended for production. Docs ↗.

For Domain Authentication: Settings → Sender Authentication → Authenticate Your Domain. Pick your DNS host; SendGrid generates 3 CNAME records:

  • em1234.yourdomain.com → SendGrid's mail server
  • s1._domainkey.yourdomain.com → DKIM record 1
  • s2._domainkey.yourdomain.com → DKIM record 2

Add at your DNS provider; come back to SendGrid and click Verify. Usually green in 10–30 minutes.

Generate an API key

3

Settings → API Keys → Create API Key. Pick:

  • API Key Name — descriptive (e.g., "production-server").
  • API Key Permissions — pick Restricted Access and grant only what your app needs. For just sending: Mail Send: Full. Avoid Full Access for production.

Copy the key (starts with SG.). Shown once. Store in env:

SENDGRID_API_KEY=SG.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Install the SDK

4
npm install @sendgrid/mail

Other languages: Python, Ruby, PHP, Java, C#, Go ↗.

Send your first email

5
import sgMail from "@sendgrid/mail";

sgMail.setApiKey(process.env.SENDGRID_API_KEY);

await sgMail.send({
  to: "[email protected]",
  from: "[email protected]",            // must be a verified sender
  subject: "Hello from SendGrid",
  text: "Plain text version",
  html: "<p>HTML body</p>",
});

Check your recipient. If it's not there, look at Activity in the SendGrid dashboard — every send is logged with its delivery status and the recipient mail server's response.

Use Dynamic Templates

6

For repeatable emails (welcome, receipt, password reset), use Dynamic Templates — designed in the SendGrid dashboard, sent by ID.

Email API → Dynamic Templates → Create Template. Use the drag-and-drop editor or HTML editor. Variables look like {{name}} using Handlebars syntax.

Send by template ID:

await sgMail.send({
  to: user.email,
  from: "[email protected]",
  templateId: "d-xxxxxxxxxxxxxxxxxxxxxxxx",     // starts with d-
  dynamicTemplateData: {
    name: user.name,
    verifyUrl: `https://yourapp.com/verify/${token}`,
  },
});

Editing the template in the dashboard updates all future sends immediately — no deploy needed.

Webhooks for delivery events

7

Settings → Mail Settings → Event Webhook. Add your endpoint URL. Pick events: delivered, opened, clicked, bounced, dropped, spam reported.

SendGrid POSTs your URL with batches of events. Enable signed event webhooks for security — SendGrid signs the payload with a key you verify on your end. Signed webhook docs ↗.

What to do with the events:

  • Bounced — mark recipient as invalid; stop sending until you re-verify the address.
  • Spam reported — same; this user actively flagged your mail as spam.
  • Delivered / opened / clicked — feed into your analytics (e.g., PostHog) for engagement tracking.

IP warmup (if you scale up)

8

Shared IPs are the default on free / starter plans. At higher volume you can request a dedicated IP — but a new IP has no sending reputation. You need to "warm it up" by gradually increasing volume over 4–6 weeks.

SendGrid automates this: enable IP warmup in account settings; SendGrid throttles your sends to safe daily limits that ramp up over time. Skip the warmup and you'll land in spam everywhere.

IP warmup schedule ↗. For volumes under ~100K/month, the shared IP pool is fine.

Sub-accounts (Pro+ plans)

9

SendGrid's Subusers feature lets a single SendGrid account own multiple sub-accounts with their own API keys, sender authentication, and IP pools. Useful when you have multiple products or run a multi-tenant platform.

Settings → Subuser Management. Create a subuser with its own credentials; assign IP pools and limits. Subusers docs ↗.

Most indie/SaaS users don't need this. Pick a different provider if you're not at the scale that justifies a multi-account hierarchy.

Common failures

10
  • "The from address does not match a verified Sender Identity" — the sender wasn't verified, or you typed a different address than what you verified. Recheck Sender Authentication.
  • "Account temporarily blocked" — SendGrid's anti-abuse system flagged something. Usually clears in a few hours; contact support if it persists.
  • "Maximum credits exceeded" — you hit your plan's daily/monthly cap. Upgrade or wait.
  • Emails delivered but going to spam — almost always missing DNS records. Check Sender Authentication status; make sure DMARC is set up too.
SendGrid is the most-used spammer's choice too. Because of historical abuse, some receivers (especially smaller mail servers) treat SendGrid IPs with more suspicion. For maximum deliverability at modest scale, Postmark often performs better despite the higher per-email cost.

Pricing reality

11

Free: 100 emails/day forever (after a 60-day 40K/month trial). Essentials: $19.95/mo for 50K emails. Pro: $89.95/mo for 100K + dedicated IP. SendGrid pricing ↗.

Per-email cost is competitive at scale ($0.0004 / email at the millions-per-month tier). For < 50K/month, Resend is cheaper for the same DX.

Official references

What's next