Troubleshooting / FAQ
Common Errors
"Mail not configured. Call Mail.configure() before using Mail facade."
You must call Mail.configure() before using any Mail.* methods:
Mail.configure({
default: 'smtp',
from: { address: 'noreply@example.com', name: 'App' },
mailers: {
smtp: { driver: 'smtp', host: 'localhost', port: 587 },
},
});"SendGrid provider requires @sendgrid/mail package"
Install the peer dependency for the provider you are using:
SendGrid
npm install @sendgrid/mailAWS SES
npm install @aws-sdk/client-sesMailgun
npm install mailgun.js form-dataResend
npm install resendPostmark
npm install postmark"Handlebars is not installed" / "EJS is not installed" / "Pug is not installed"
Install the template engine you configured:
for engine: 'handlebars'
npm install handlebarsfor engine: 'ejs'
npm install ejsfor engine: 'pug'
npm install pug"marked is not installed" / "juice is not installed"
Markdown Mail requires both marked and juice:
npm install marked juice"Queue not configured. Add queue configuration to Mail.configure()"
Add a queue section to your configuration:
Mail.configure({
// ...
queue: {
driver: 'bullmq',
connection: { host: 'localhost', port: 6379 },
},
});"BullMQ is not installed" / "Bull is not installed"
Install the queue driver you configured:
for driver: 'bullmq'
npm install bullmq ioredisfor driver: 'bull'
npm install bull"Mailer 'xxx' is not configured"
The mailer name you are using does not exist in your configuration. Check that the name matches a key in your mailers object:
Mail.configure({
mailers: {
smtp: { ... }, // Mail.mailer('smtp') works
sendgrid: { ... }, // Mail.mailer('sendgrid') works
},
});
Mail.mailer('resend'); // Error: not configured"Mail::fake() must be called before using assertions."
Call Mail.fake() before using any assertion methods:
Mail.fake(); // Must be called first
await Mail.to('user@example.com').send(new WelcomeEmail('John'));
Mail.assertSent(WelcomeEmail); // Now this worksPeer Dependency Guidance
The package uses peer dependencies to keep the base installation lightweight. Only install what you need:
| Feature | Required Packages |
|---|---|
| SMTP | (included) |
| SendGrid | @sendgrid/mail |
| AWS SES | @aws-sdk/client-ses |
| Mailgun | mailgun.js, form-data |
| Resend | resend |
| Postmark | postmark |
| Handlebars templates | handlebars |
| EJS templates | ejs |
| Pug templates | pug |
| Markdown Mail | marked, juice |
| BullMQ queue | bullmq, ioredis |
| Bull queue | bull |
Best Practices
- Use environment variables for all API keys and credentials.
- Configure failover in production for reliability.
- Use
Mail.fake()in tests to avoid sending real emails. - Use the sync queue driver in development/testing, BullMQ in production.
- Enable template caching in production for better performance.
- Use Mailable classes for reusable, testable email definitions.