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
- A jobs table with status, attempts, next attempt time and last error.
- A worker that claims jobs safely so two runs never send the same email.
- Retries with growing delays, stopping after a set number of attempts.
- Templates in separate files, with every user value escaped.
- A bounce and complaint webhook that verifies the sender and adds hard bounces to a suppression list.
- No send to any address on that list.
Output format
- Schema, worker code and webhook code in separate blocks.
- A short note on running the worker by cron or as a service.
- Tests for retry, suppression and duplicate claim.
Guardrails
- Credentials only from environment variables.
- Never log full email bodies.






