Email Drivers
Laravel supports multiple email delivery methods:- SMTP - Standard SMTP server (Gmail, Mailgun, etc.)
- Mailgun - Mailgun API integration
- Postmark - Postmark API integration
- Amazon SES - AWS Simple Email Service
- Resend - Resend API integration
- Log - Write emails to log files (development only)
- Array - Store emails in memory (testing only)
The application defaults to the
log driver for development. Configure a real mail driver for production.SMTP Configuration
The most common email configuration uses SMTP:Environment Variables
The default mail driver. Set to
smtp for SMTP delivery.The SMTP server hostname.
The SMTP server port. Common ports:
25- Standard SMTP (usually blocked by ISPs)587- TLS/STARTTLS (recommended)465- SSL2525- Alternative port (Mailgun, Mailtrap)
SMTP authentication username.
SMTP authentication password.
Encryption method. Options:
tls, ssl, or leave empty for no encryption.Use
tls for port 587, ssl for port 465.The default “from” email address for all outgoing emails.
The default “from” name for all outgoing emails. Supports variable substitution.
Provider-Specific Configuration
Gmail
Using Gmail for SMTP (not recommended for production):Mailgun
Professional email delivery service:Mailtrap (Development)
Email testing service for development:Mailtrap captures all emails without delivering them. Perfect for testing email functionality.
Postmark
Transactional email service with high deliverability:Amazon SES
AWS Simple Email Service:Resend
Modern email API:Development Configuration
For local development, use the log driver to preview emails:.env
storage/logs/laravel.log:
Testing Email Configuration
Test your email configuration:Email Types Sent by the Application
The application sends various transactional emails:Authentication Emails
- Email Verification - Sent when new users register
- Password Reset - Sent when users request password reset
- Two-Factor Authentication - 2FA codes if enabled
Tenant Management Emails
- Tenant Created - Welcome email for new tenants
- User Invitation - Invite users to join a tenant
- Role Changed - Notification when user role changes
Subscription Emails
- Subscription Created - Confirmation of new subscription
- Subscription Renewed - Renewal confirmation
- Subscription Canceled - Cancellation confirmation
- Payment Failed - Notification of failed payment
- Trial Ending Soon - Reminder before trial expires
System Notifications
- Activity Alerts - Important system activity
- Security Alerts - Suspicious login attempts
- System Updates - Maintenance notifications
Customizing Email Templates
Email templates are located inresources/views/emails/:
Email Queuing
For better performance, queue emails instead of sending synchronously:.env
In production, use a process manager like Supervisor to keep the queue worker running.
Advanced Configuration
Multiple Mail Configurations
Use different mail configurations for different email types:Failover Configuration
Automatically fallback to another mailer if the primary fails:.env
Per-Tenant Email Configuration
Configure different email settings per tenant:Production Best Practices
SPF Record
Add to your DNS:DKIM Record
Obtain from your email provider and add to DNS.DMARC Record
Rate Limiting
Implement rate limiting to prevent abuse:Email Verification
Ensure your email sender identity is verified with your provider.Monitoring
- Track email delivery rates
- Monitor bounce rates
- Set up alerts for failed deliveries
- Log all email sending attempts
Troubleshooting
Emails Not Sending
Connection Timeout
- Verify SMTP host and port
- Check firewall rules
- Ensure the port is not blocked by your hosting provider
Authentication Failed
- Verify username and password
- Check if 2FA/app passwords are required
- Ensure SMTP authentication is enabled
Emails Going to Spam
- Configure SPF, DKIM, and DMARC
- Use a reputable email service
- Avoid spam trigger words
- Include unsubscribe links
- Maintain a good sender reputation
Environment Examples
Next Steps
- Learn about tenant management to understand tenant-specific emails
- Configure background jobs for email queuing
- Set up monitoring to track email delivery