What this thread does
Queue a notification reference in BullMQ, render React Email in the worker, and verify generated MIME before enabling real delivery.
Do first: set streamTransport: true in email-smoke.tsx for the non-delivering worker test.
Use a disposable Redis queue and Nodemailer's stream transport so the first test produces message bytes without sending mail. The worker runtime must support your project's TSX setup. Install stable dependencies and lock them in that project; as of November 2026, the current release references are BullMQ 6.7.8 (2026-11-19) and react-email 6.11.16 (2026-11-17), checked 2026-11-23. This is a new setup, not an upgrade recipe.
1. Separate the web producer from the long-running worker process. For the first test they may share a script; production deployment must actually keep a worker running. 2. Use an immutable notification ID and template version. Real jobs should carry a reference to the notification record, with recipient/props loaded by authorized worker code. Keep reset tokens and unnecessary personal data out of queue logs. 3. Adapt this self-contained smoke script as email-smoke.tsx. It assumes Redis is reachable as redis:6379 from the worker; replace the connection with your development connection settings. All addresses below are test placeholders.
import React from 'react';
import { Html, Text, render, toPlainText } from 'react-email';
import { Queue, Worker } from 'bullmq';
import nodemailer from 'nodemailer';
const connection = { host: 'redis', port: 6379 };
const transport = nodemailer.createTransport({
streamTransport: true, buffer: true
});
const queue = new Queue('email-smoke', { connection });
const worker = new Worker('email-smoke', async job => {
const html = await render(<Html lang="en">
<Text>Hello {job.data.displayName}, your receipt is ready.</Text>
</Html>);
const result = await transport.sendMail({
from: 'sender@example.com', to: 'recipient@example.com',
subject: 'Receipt', html, text: toPlainText(html)
});
if (!Buffer.isBuffer(result.message)) throw new Error('Missing MIME');
console.log(result.message.toString());
}, { connection, concurrency: 1 });
worker.on('error', error => console.error(error.message));
await queue.add('receipt-v1', { displayName: 'Test Reader' }, {
jobId: 'receipt-smoke-001', attempts: 3,
backoff: { type: 'exponential', delay: 1000 }
});
Run it with the project's TSX-capable runner. Expect an HTML and plain-text MIME body and a completed job. The worker remains running; stop it after inspecting the output. Use a fresh test ID on a later run if the completed job is retained. The example's concurrency/backoff values are demonstration choices, not provider quotas.
Rendering API: React Email render. Non-delivering transport: Nodemailer stream transport. Retry behavior: BullMQ retries. Job IDs are unique within a queue while the job exists; removing it removes that duplicate check. Job IDs.
4. Replace stream delivery with your chosen provider integration only after the MIME test passes. Keep one reusable SMTP transporter per worker process when using SMTP. Match worker concurrency/rate limits to the provider's actual allowance; no universal allowance is established here. Nodemailer SMTP. 5. Retry transient failures with bounded backoff; route permanent address/template failures for inspection. Track the age of the oldest waiting notification, terminal failures and provider acceptance IDs. A completed queue job is not proof of inbox delivery. 6. Add durable notification state and, if needed, a transactional outbox so committing the business event and scheduling the notification cannot silently diverge. A crash after a provider accepts a message but before the worker records completion can duplicate delivery. Use the provider's documented idempotency facility when available, otherwise define reconciliation for ambiguous outcomes; SMTP plus a local sent flag does not promise exactly once. Idempotent job guidance.
Component decisions and limits — checked 2026-10-28
| Component | For / wins | Loses | Cost or limit; pick this if |
|---|---|---|---|
| BullMQ | Durable scheduling/retries with separate workers | Nobody operates the queue backend or worker lifecycle | MIT per connections docs; backend hosting costs remain. Redis must use maxmemory-policy=noeviction. Pick this when the application needs background delivery. |
| React Email | Versioned reusable templates in React | The team does not use a JSX/TSX build workflow | A renderer, not a sending quota or queue. Pick this when shared React templates reduce duplication. |
| Nodemailer | SMTP delivery or local MIME generation | You need provider-only API features | Transport library, not a mailbox-delivery service. Provider charges and limits are separate. Pick this for SMTP portability or a stream-based smoke test. |
Solo default: one queue and worker with an existing provider. Small team: the same plus notification state, a failed-job view and template ownership. Enterprise: use the established delivery service and agreed replay policy; avoid introducing a second retry system without defining who owns it. These are recommendations.
Public evidence
Issue 3427, jtomaszewski, 2025-09-04: “while avoiding unnecessary duplicate executions”. The request illustrates that trigger deduplication has application-specific semantics; it is not proof of exactly-once email. Evidence: none found for an end-to-end user trial of this exact current stack.
Prompt for your agent
Implement a non-delivering queued-template smoke test first. Then define notification identity, template version, retry classification and recovery after an ambiguous provider response. Show HTML/text output and failed-job handling without sending real messages.
Mistakes and Limits
Do not enqueue only after an HTTP response without a durable handoff; do not retry invalid recipients forever or remove all completed jobs while relying on their IDs for permanent deduplication. No script, Redis worker, SMTP connection or client-rendering matrix was run. Template output and retry/recovery paths require application tests before real sending. Provider selection, sender authentication and spam placement belong in the related thread. checked 2026-10-28
Started from a post by @Taskforce.sh, packaged by the editor. Original post