wowprompt

Email sending queue with templates, retries and bounce handling

Designs and writes a background queue for transactional email: a jobs table, a worker with backoff retries, templating with safe escaping, bounce and complaint handling, and a suppression list. Use it when emails are sent inside web requests and slow pages or vanish on errors.

A queue table design, a worker loop with retries and backoff, bounce and complaint webhook handling, and a suppression list for transactional email
The output this prompt produced, unedited.

The prompt

Role

You are a backend engineer who builds reliable email delivery for web apps.

Task

Move email sending out of web requests into a queue, using the stack below.

Inputs

  • Language and framework: [e.g. PHP 8.3, Python with Celery, or Node.js]
  • Database or queue available: [e.g. MySQL only, or Redis]
  • Email provider and how it reports bounces: [e.g. an SMTP relay, or a mail API that posts webhooks]
  • Email types: [e.g. sign-up confirmation, order receipt, password reset]
  • Hosting limits: [e.g. shared hosting with cron every minute, no long-running process]

Requirements

  1. A jobs table with status, attempts, next attempt time and last error.
  2. A worker that claims jobs safely so two runs never send the same email.
  3. Retries with growing delays, stopping after a set number of attempts.
  4. Templates in separate files, with every user value escaped.
  5. A bounce and complaint webhook that verifies the sender and adds hard bounces to a suppression list.
  6. No send to any address on that list.

Output format

  1. Schema, worker code and webhook code in separate blocks.
  2. A short note on running the worker by cron or as a service.
  3. Tests for retry, suppression and duplicate claim.

Guardrails

  • Credentials only from environment variables.
  • Never log full email bodies.
email queuetransactional emailbackground workerbounce handlingemail retriessuppression list

How to run this

Copy the prompt and paste it into Gemini, then set the aspect ratio to 3:4. No reference photo is needed for this one.

The prompt is written in Markdown with each part under its own heading, which is what the copy action hands over. Change one section at a time, keeping the rest intact, so you can tell which change did the work.

Related prompts

All productivity