Skip to content

fix(api-mailer): smtp usage#5253

Merged
brunozoric merged 10 commits into
nextfrom
bruno/fix/api-mailer-smtp
May 27, 2026
Merged

fix(api-mailer): smtp usage#5253
brunozoric merged 10 commits into
nextfrom
bruno/fix/api-mailer-smtp

Conversation

@brunozoric
Copy link
Copy Markdown
Contributor

@brunozoric brunozoric commented May 27, 2026

Summary

The SMTP transport in @webiny/api-mailer could not negotiate TLS/SSL connections because nodemailer's secure option was never set. This made it impossible to connect to modern SMTP providers (Gmail, AWS SES, etc.) that require explicit TLS configuration.

Changes

  • Added secure field to TransportSettings — threaded through the full stack: types, GraphQL schema (input + response), validation, save/get repositories, and SmtpConfig mapping to nodemailer.
  • Changed the default port from 25 to 587 — port 25 is blocked by most cloud providers (AWS, GCP, Azure). Port 587 (STARTTLS) is the modern standard.
  • Auto-detection — when secure is not explicitly set, it defaults to true for port 465 (implicit TLS) and false otherwise.
  • Introduced TransportCreateError — transport factory failures now return a distinct error type with the code Mailer/MailerService/TransportCreateError, instead of reusing TransportSendError which has a different shape and misleading semantics.
  • Wrapped transport creation in try-catch — if nodemailer.createTransport() throws during construction (e.g., config validation), the error is caught and returned as a Result.fail instead of propagating as an unhandled exception.

@brunozoric brunozoric added this to the 6.4.0 milestone May 27, 2026
@brunozoric brunozoric self-assigned this May 27, 2026
@brunozoric brunozoric force-pushed the bruno/fix/api-mailer-smtp branch from e490b68 to f9a8408 Compare May 27, 2026 10:08
brunozoric and others added 10 commits May 27, 2026 12:51
Add `secure` field to TransportSettings so nodemailer can negotiate
TLS correctly. Change default port from 25 (blocked by most cloud
providers) to 587 (STARTTLS). Wrap transport factory creation in
try-catch to prevent unhandled exceptions from crashing the request.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Introduce a distinct TransportCreateError for factory failures instead
of reusing TransportSendError (wrong shape and misleading error code).
Add tests for port-465 auto-detection of secure: true and explicit
override. Clean up redundant EventPublisher alias import.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test handler in @webiny/testing registered createBackgroundTaskContext
but not createBackgroundTaskGraphQL, causing tests in api-scheduler and
api-workflows to fail with "Unknown type WebinyBackgroundTaskError"
after the background task settings feature was added.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… chain

Remove ActiveTransport in favor of iterating registered transports from
last to first, using each factory's canUse() method to determine if it
has the settings it needs. SMTP is tried first (registered last); if no
settings exist, DummyTransport takes over (canUse always returns true).
This makes DummyTransport the natural dev/testing fallback and removes
the hard NoSettingsConfiguredError when SMTP isn't configured.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Include a .yarnrc.yml in scaffolded projects with enableScripts: false,
npmMinimalAgeGate: 3d, preapproved @webiny/* and wts-client packages,
and the approved webiny-upgrades-v6 git repository.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@brunozoric brunozoric force-pushed the bruno/fix/api-mailer-smtp branch from 3f4b52f to 1126faf Compare May 27, 2026 11:16
@brunozoric brunozoric marked this pull request as ready for review May 27, 2026 11:45
@brunozoric brunozoric merged commit 278c647 into next May 27, 2026
30 checks passed
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.

1 participant