Vigia

Upgrading @nestjs-modules/mailer from 3.x to 4.x

Comparison of the public API of @nestjs-modules/mailer 3.0.2 and 4.0.0, computed automatically from their TypeScript types. A changed signature is a candidate for a breaking change, not a certainty.

Summary

Removed import paths0
Removed exports0
Changed signatures0
Removed class or interface members1
Changed class or interface members3
Newly deprecated0
Requirement changes (engines, peer dependencies)3
New exports64

Removed exports

None detected.

Changed signatures

None detected.

Removed class or interface members

memberimportBefore
MailerService.executeSend@nestjs-modules/mailerany

Changed class or interface members

memberBeforeAfter
MailerService.constructor(mailerOptions: MailerOptions, transportFactory: MailerTransportFactory, eventService?: MailerEventService | undefined): MailerService(mailerOptions: MailerOptions, transportFactory?: MailerTransportFactory | undefined, eventService?: MailerEventService | undefined, moduleRef?: any): MailerService
MailerTestModule.static register(options?: Partial<{ template: { dir?: string | undefined; adapter?: any; options?: any; }; }> | undefined): DynamicModule(options?: Omit<MailerOptions, "transport" | "transports"> | undefined): DynamicModule
MailerEventService.constructor(eventEmitter?: any): MailerEventService(eventEmitter?: MailerEventEmitter | undefined, moduleRef?: any): MailerEventService

Newly deprecated

None detected.

Requirement changes (engines, peer dependencies)

BeforeAfter
peerDependencies.handlebars>=4.7.9>=4.7.10
peerDependencies.@nestjs/mail—>=0.0.1
peerDependencies.@nestjs/outbox—>=0.1.3
New exports (64)
importexportkind
@nestjs-modules/mailerhtmlfunction
@nestjs-modules/mailersignV4function
@nestjs-modules/mailerMailableinterface
@nestjs-modules/mailerSafeHtmlclass
@nestjs-modules/mailerMailQueryinterface
@nestjs-modules/mailerhtmlToTextfunction
@nestjs-modules/mailerisSafeHtmlfunction
@nestjs-modules/mailerunsafeHtmlfunction
@nestjs-modules/mailerMailerErrorclass
@nestjs-modules/mailerTestMailboxclass
@nestjs-modules/mailerCapturedMailclass
@nestjs-modules/mailerLogTransportclass
@nestjs-modules/mailerMailableDatatype
@nestjs-modules/mailerRenderedMailinterface
@nestjs-modules/mailerSesTransportclass
@nestjs-modules/mailerSigV4Optionsinterface
@nestjs-modules/mailerSigV4Requestinterface
@nestjs-modules/mailerFileTransportclass
@nestjs-modules/mailerMailerPreviewtype
@nestjs-modules/mailertoMailerErrorfunction
@nestjs-modules/mailerAwsCredentialsinterface
@nestjs-modules/mailerBrevoTransportclass
@nestjs-modules/mailerSigV4Signatureinterface
@nestjs-modules/mailerLOCAL_TRANSPORTvariable
@nestjs-modules/mailerMailableContenttype
@nestjs-modules/mailerMailableContextinterface
@nestjs-modules/mailerMailerSmtpErrorclass
@nestjs-modules/mailerResendTransportclass
@nestjs-modules/mailerparseRetryAfterfunction
@nestjs-modules/mailervalidateMessagefunction
@nestjs-modules/mailerInterceptOptionsinterface
@nestjs-modules/mailerMailgunTransportclass
@nestjs-modules/mailerisTransientErrorfunction
@nestjs-modules/mailerMailerEventRecordinterface
@nestjs-modules/mailerPostmarkTransportclass
@nestjs-modules/mailerSendGridTransportclass
@nestjs-modules/mailermailerChannelNamefunction
@nestjs-modules/mailerMailerEventEmitterinterface
@nestjs-modules/mailerMailerMessageErrorclass
@nestjs-modules/mailerMailerRetryOptionsinterface
@nestjs-modules/mailerMailerTimeoutErrorclass
@nestjs-modules/mailerUnsubscribeOptionsinterface
@nestjs-modules/mailerHttpSentMessageInfointerface
@nestjs-modules/mailerLogTransportOptionsinterface
@nestjs-modules/mailerMailableSendOptionstype
@nestjs-modules/mailerMailerPreviewModuleclass
@nestjs-modules/mailerMailerProviderErrorclass
@nestjs-modules/mailerMailerTemplateErrorclass
@nestjs-modules/mailerSesTransportOptionsinterface
@nestjs-modules/mailerFileTransportOptionsinterface
@nestjs-modules/mailerHttpTransportOptionsinterface
@nestjs-modules/mailerMAILER_EVENT_EMITTERvariable
@nestjs-modules/mailerMailerPreviewOptionsinterface
@nestjs-modules/mailermayHaveBeenDeliveredfunction
@nestjs-modules/mailerBrevoTransportOptionsinterface
@nestjs-modules/mailerHttpProviderTransportclass
@nestjs-modules/mailerMailerConnectionErrorclass
@nestjs-modules/mailerSuppressedMessageInfointerface
@nestjs-modules/mailerMAILER_PREVIEW_OPTIONSvariable
@nestjs-modules/mailerResendTransportOptionsinterface
@nestjs-modules/mailerMailgunTransportOptionsinterface
@nestjs-modules/mailerPostmarkTransportOptionsinterface
@nestjs-modules/mailerSendGridTransportOptionsinterface
@nestjs-modules/mailerMailerRecipientsRejectedErrorclass

Changelog between these versions

Text published by the package authors, shown as-is.

4.0.0
### Major Changes

- [#1353](https://github.com/nest-modules/mailer/pull/1353) [`c8c0423`](https://github.com/nest-modules/mailer/commit/c8c0423749bd8f0f7d0f247e62ee5ab7a55f6535) Thanks [@juandav](https://github.com/juandav)! - v4: everything the official `@nestjs/mail` offers and more, without dropping anything v3 supports. Every capability is optional: use nodemailer, the built-in HTTP providers or `@nestjs/mail`'s transports; send directly, through BullMQ or through `@nestjs/outbox`; call `sendMail`, mail classes or the official `Mailer` over this module.
  
  **Breaking changes** (see the [migration guide](https://nest-modules.github.io/mailer/guide/migration)):
  
  - Transient failures are retried by default (3 attempts with backoff); `retry: false` restores v3. A timeout or a dropped connection while the message was being handed over is retried only when the email has a stable Message-ID (`idempotencyKey`), so nothing is sent twice. `sendTimeout` applies per attempt.
  - Errors from transports are typed (`MailerSmtpError`, `MailerTimeoutError`, … all `MailerError`), keeping nodemailer's fields and the original as `cause`; `wrapErrors: false` restores v3.
  - Emails without a text part get one derived from the HTML (`textFromHtml: false` to opt out), and messages are validated before sending (`validate: false` to opt out).
  - `MailerTestModule` delivers to a `TestMailbox` (no stream transport; `info.message` uses CRLF line endings) and defaults `retry` to `false`.
  - `MailerPreviewModule` is on by default only when `NODE_ENV` is `development` or `test`.
  - Event payloads carry `attempt`, `permanent`, `transporterName` and `durationMs`; `MailerEventService` takes its emitter through `MAILER_EVENT_EMITTER`, and `EventEmitter2` is found automatically (in v3 it was never injected).
  - `MailableContext.to` is `{ name?, address }[]`, the same shape as `@nestjs/mail`.
  
  **New**
  
  - Mail classes (`mailerService.send(WelcomeMail, { to, data })`) compatible with `@nestjs/mail`'s, with dependencies resolved from the whole app, and `render()` to render without sending.
  - Retries with backoff and error classification (nodemailer, HTTP and AWS SDK errors), failover between transporters, `AbortSignal`, `idempotencyKey`, and graceful shutdown that waits for sends in flight (`shutdownTimeout`).
  - Zero-dependency HTTP transports: Resend, Postmark, SendGrid, SES (SigV4), Mailgun and Brevo.
  - The `html` tagged template (`unsafeHtml()` for trusted markup), `htmlToText()` and message validation.
  - `intercept` (redirect recipients in staging), `suppress` (suppression lists) and one-click `unsubscribe` (RFC 8058).
  - `TestMailbox` with assertions, `FileTransport` and `LogTransport` (with a warning when used in production) and `MailerPreviewModule` to preview emails in the browser.
  - `events$`, `node:diagnostics_channel` publishing (credentials redacted), and `RETRY`, `FAILOVER` and `SUPPRESSED` events.
  - BullMQ: permanent failures fail the j

Give your AI agent these facts

Vigia is a free MCP server: your coding agent checks versions, breaking changes and vulnerabilities before it writes code. No signup, no API key.

claude mcp add --transport http vigia https://vigia.coredls.cloud/mcp

Add to CursorAdd to VS Code★ Star on GitHub

Any other MCP client
{ "mcpServers": { "vigia": { "url": "https://vigia.coredls.cloud/mcp" } } }

Agent skill (SKILL.md): tells the agent when to use Vigia · GitHub Action for pull requests

Frequently asked questions

What are the breaking changes when upgrading @nestjs-modules/mailer from 3 to 4?

Between @nestjs-modules/mailer 3.0.2 and 4.0.0, Vigia found 0 removed exports, 0 changed signatures and 4 removed or changed class or interface members.

What became deprecated in @nestjs-modules/mailer 4?

0 exports or members are newly marked as deprecated in @nestjs-modules/mailer 4.0.0.

For agents

GET https://vigia.coredls.cloud/v1/packages/npm/@nestjs-modules/mailer/upgrade?from=3.0.2&to=4.0.0