Guides
Email setup
Configure SMTP for password reset and email verification emails.
Email setup
Auth Service uses Nodemailer to send password reset and email verification emails. Email is entirely optional — all SMTP settings are omitted by default and Auth Service silently skips sending if SMTP_HOST is not set.
Configuration
Set the following environment variables:
SMTP_HOST=smtp.example.com
SMTP_PORT=587 # defaults to 587
SMTP_USER=user@example.com
SMTP_PASS=your-smtp-password
SMTP_FROM=Auth Service <no-reply@example.com>
SMTP_PORT=465 automatically enables TLS (secure: true). All other ports use STARTTLS negotiation.
If SMTP_USER and SMTP_PASS are both empty, Nodemailer connects without authentication — useful for local SMTP relays.
Emails sent
| Trigger | Subject |
|---|---|
| User requests a password reset | Reset your password |
User registers when requireEmailVerification is enabled | Verify your email |
requireEmailVerificationisfalseby default insrc/auth.ts. Enable it in the BetterAuth configuration if you want to require email verification before users can sign in.
Testing with a local SMTP relay
Use Mailhog or smtp4dev locally:
# docker-compose.dev.yml addition
mailhog:
image: mailhog/mailhog
ports:
- "1025:1025" # SMTP
- "8025:8025" # Web UI
SMTP_HOST=localhost
SMTP_PORT=1025