BoilerPrompt
GitHub Copilot

GitHub Copilot prompt to add email notifications

The dangerous part of email is not sending it, it is sending it twice, or to a real customer from your laptop. This prompt directs GitHub Copilot to build a flag-gated mailer with typed payloads, post-commit sends, and a browser preview route, so nothing reaches an inbox by accident.

Last updated

Prompt
Add transactional email to this app using {{addon}} for delivery. Create lib/mailer exposing one function per message type, welcomeEmail and passwordResetEmail to start, each taking a typed payload rather than a raw template string. Templates live in emails/ as one file per message with plain-text and HTML variants generated from the same content, since some corporate inboxes strip HTML. Sends must happen after the triggering database write commits, never inside the transaction, and a provider failure logs the message id and payload without crashing the request that triggered it. Gate everything behind an EMAIL_ENABLED flag that defaults off in development so local signups never mail real users. Add a dev-only preview route listing rendered templates in the browser. When you finish, list changed files and point out where retries would go. I will verify by triggering a signup locally with the flag on and a sandbox key.

Customize it

Runs in your browser. Nothing you type here is sent anywhere.

Your customized prompt
Add transactional email to this app using input validation for delivery. Create lib/mailer exposing one function per message type, welcomeEmail and passwordResetEmail to start, each taking a typed payload rather than a raw template string. Templates live in emails/ as one file per message with plain-text and HTML variants generated from the same content, since some corporate inboxes strip HTML. Sends must happen after the triggering database write commits, never inside the transaction, and a provider failure logs the message id and payload without crashing the request that triggered it. Gate everything behind an EMAIL_ENABLED flag that defaults off in development so local signups never mail real users. Add a dev-only preview route listing rendered templates in the browser. When you finish, list changed files and point out where retries would go. I will verify by triggering a signup locally with the flag on and a sandbox key.

Same task in other tools

Questions about this prompt

Why must sends wait until the database write commits?

An email fired inside the transaction can announce an account that rolls back a moment later. Commit first, send after, and accept that a crash between the two loses an email rather than tells a lie.

How do I add another message type like an invoice receipt?

Add one typed function to lib/mailer and a matching template pair in emails/. Ask Copilot to mirror the shape of welcomeEmail and it will carry over the payload typing and both variants.

Templates look right in the preview route but break in Outlook. Why?

The preview shows browser rendering, and Outlook uses a much older engine. Keep HTML layout table-based and simple, lean on the plain-text variant, and check with your provider's inbox preview tooling.

Related prompts