Sending Emails
Wire auth events to Resend, SendGrid, AWS SES, or Postmark.
Nest Auth never sends an email itself. It generates the codes and tokens, then emits an event. Your listener delivers the message.
Events that emit emails
| Event | When | Has |
|---|---|---|
EmailVerificationRequestedEvent | User signs up or asks to verify | user, code |
PasswordResetRequestedEvent | User clicks "forgot password" | user, code |
PasswordlessCodeRequestedEvent (channel: 'email') | Passwordless / magic-link send | identifier, code |
TwoFactorCodeSentEvent (method: 'email') | MFA email-OTP challenge | user, code |
EmailVerifiedEvent | After verification succeeds | user |
PasswordResetEvent | After reset succeeds | user |
Most apps wire all six in one listener service.
With Resend
Register the listener in your module:
With SendGrid
With AWS SES
Templates
Hard-coded HTML works for the first version, but break out templates as soon as you have more than two emails:
- React Email + Resend (compose with JSX, render on the server).
- MJML for cross-client rendering.
- Provider-hosted templates (SendGrid, Postmark) for marketing teams to edit without redeploying.
Don't block the response
Listeners run async — the auth response returns regardless of whether your email send completes. Don't await slow operations if you want fast logins. Push the actual send into a queue:
This also makes retries trivial.
Testing without sending
In tests, swap your real provider for a mock:
Or no-op the whole listener — your unit tests for the auth flow shouldn't depend on email delivery succeeding.
Related
- Sending SMS — same pattern for the phone equivalents.
- Events reference — every emitted event with payload.