Skip to content

feat(queue): implement real email transport in the email processor#587

Open
Wittig18 wants to merge 1 commit into
Talenttrust:mainfrom
Wittig18:feature/queue-31-email-transport
Open

feat(queue): implement real email transport in the email processor#587
Wittig18 wants to merge 1 commit into
Talenttrust:mainfrom
Wittig18:feature/queue-31-email-transport

Conversation

@Wittig18

Copy link
Copy Markdown
Contributor

Summary

  • Closes Implement a real email transport in the email queue processor #362
  • Replaces the simulated simulateEmailSend timeout in the email queue processor with a pluggable EmailTransport selected from validated env config (EMAIL_PROVIDER, SMTP/SES/SendGrid settings).
  • Provider failures now throw so BullMQ marks the job failed and retries instead of returning { success: true } with no delivery.
  • Adds strict recipient validation and CR/LF header-injection guards; logs use the structured logger without full recipient addresses or bodies at info level.

Changes

  • src/queue/processors/email.transport.tsEmailTransport interface, ConsoleEmailTransport, SendGridEmailTransport (SendGrid v3 REST via axios), SmtpEmailTransport, SesEmailTransport (AWS SigV4), setEmailTransportOverride() for tests.
  • src/queue/processors/email-processor.ts — Validates payload, dispatches via resolveEmailTransport(), preserves { success, message, data: { emailId } } return shape.
  • src/config/env.schema.ts — Email transport env vars with Zod validation.
  • src/queue/processors/email-processor.test.ts — Mock transport delivery, provider failure propagation, header-injection rejection.
  • docs/email-notifications.md — Queue processor transport selection and config.

Config

Variable Purpose
EMAIL_PROVIDER console (default), smtp, ses, sendgrid
EMAIL_SEND_TIMEOUT_MS Provider call timeout (default 10000)
SMTP_* SMTP host/port/from/credentials
AWS_* SES credentials and region
SENDGRID_API_KEY SendGrid API key

Test plan

  • npm run lint
  • npm test -- src/queue/processors/email-processor.test.ts
  • Enqueue an email-notification job with EMAIL_PROVIDER=console and confirm success
  • Inject a failing transport (or misconfigure provider) and confirm the job fails/retries
  • Confirm invalid recipient / header-injection payloads reject before dispatch

Co-authored-by: Cursor <cursoragent@cursor.com>
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@Wittig18 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Wittig18

Wittig18 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@mikewheeleer please merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a real email transport in the email queue processor

1 participant