SendGrid
SendGrid is a sending service you reach with an API key. It works on Node, Docker and Cloudflare Workers. Use this page if you chose EMAIL_PROVIDER=sendgrid.
Settings
| Variable | Required | What it does |
|---|---|---|
EMAIL_PROVIDER | yes | Set to sendgrid. |
EMAIL_FROM | yes | The sender, as Harmony Community Choir <noreply@example.org>. |
SENDGRID_API_KEY | yes | An API key from your SendGrid account. Without it the server refuses to start with "EMAIL_PROVIDER=sendgrid needs SENDGRID_API_KEY". |
EMAIL_REPLY_TO | no | Where replies go. |
Set up SendGrid first
Either verify a single sender (SendGrid emails that address to confirm it) or authenticate your whole domain by adding the DNS records SendGrid shows you. The address in EMAIL_FROM must be covered by one of the two. Then create an API key that is allowed to send mail ("Mail Send").
A working example
EMAIL_PROVIDER=sendgrid
EMAIL_FROM="Harmony Community Choir <noreply@example.org>"
SENDGRID_API_KEY=SG.replace-with-your-key
On Cloudflare, keep EMAIL_PROVIDER and EMAIL_FROM under [vars] in wrangler.toml and set the key with wrangler secret put SENDGRID_API_KEY.
If something goes wrong
When SendGrid refuses a message, the server log has its status and reason, and the message counts as not sent:
SendGrid rejected the email: 403 Forbidden: {"errors":[{"message":"The from address does not match a verified Sender Identity. ..."}]}
That message means the sender or domain is not verified. A 401 means the API key is wrong or does not have permission to send. See Troubleshooting: nobody can log in, or emails do not arrive.