Email Providers
The starter kit is pre-configured with two email transports:- SMTP - Universal email sending (Gmail, SendGrid, etc.)
- Resend - Modern email API for developers
- Mailpit - Local email testing (development only)
Development Setup with Mailpit
Mailpit is included in the Docker Compose setup for testing emails during development.Configure SMTP for Mailpit
Your
.env file should have these settings:.env
Mailpit accepts any credentials, so the username and password don’t need to be real.
Access the Mailpit web interface
Open your browser and navigate to:All emails sent by your application will appear here, allowing you to test email templates and functionality without actually sending emails.
Production Setup with SMTP
Choose an SMTP provider
Popular SMTP providers include:
- Gmail - Free for low volume
- SendGrid - Up to 100 emails/day free
- Mailgun - Flexible pricing
- Amazon SES - Cost-effective at scale
- Postmark - Transactional email specialist
Get SMTP credentials
Each provider will give you:
- SMTP host (e.g.,
smtp.gmail.com) - SMTP port (usually
587or465) - Username (often your email address)
- Password or API key
Production Setup with Resend
Resend is a modern email API designed for developers.Create a Resend account
- Go to resend.com
- Sign up for a free account
- Verify your domain (or use the test domain)
Get your API key
- Go to API Keys in the Resend dashboard
- Create a new API key
- Copy the key (it won’t be shown again)
Mail Configuration
The mail configuration is located inconfig/mail.ts:
config/mail.ts
Creating Email Templates
The starter kit includes an example email template for password reset:app/auth/mails/reset_password_notification.ts
Sending Emails
There are several ways to send emails:Using Mail Classes
Using the Fluent API
Queuing Emails
For better performance, send emails in the background:Testing Emails
Using Mailpit (Recommended)
- Start Mailpit with Docker Compose
- Send emails from your app
- View them at
http://localhost:8025
Using the Mail Fake
Environment Variables Reference
.env.example
Troubleshooting
Emails not sending in development
Emails not sending in development
- Check that Mailpit is running:
docker ps - Verify SMTP settings match Mailpit configuration
- Check Mailpit logs:
docker logs mailpit
Gmail authentication failed
Gmail authentication failed
Gmail requires an App Password, not your regular password:
- Enable 2-factor authentication on your Google account
- Generate an App Password at myaccount.google.com/apppasswords
- Use the generated password in your
.envfile
Emails going to spam
Emails going to spam
To improve deliverability:
- Set up SPF, DKIM, and DMARC records for your domain
- Use a verified sender address
- Avoid spam trigger words in subject lines
- Include an unsubscribe link
- Use a reputable email service provider
Connection timeout
Connection timeout
Check:
- SMTP host and port are correct
- Firewall isn’t blocking SMTP ports (587, 465, 25)
- Your hosting provider allows outbound SMTP connections
Resources
AdonisJS Mail Docs
Official mail documentation
Resend
Modern email API for developers
Mailpit
Email testing tool
Edge Templates
Template engine for emails