Mail
Laravel 8
Laravel 9
Laravel 10
Laravel 11
Laravel 12
Laravel Email Sending Failed - How to Fix
This error occurs when Laravel cannot send emails due to SMTP configuration issues or server problems.
The Error
Error Message
Failed to send email / Swift_TransportException
Common Causes
- 1 Incorrect SMTP credentials
- 2 SMTP server not reachable
- 3 SSL/TLS configuration mismatch
- 4 Mail driver not properly configured
- 5 Firewall blocking outbound SMTP
Solutions
1
Configure SMTP in .env
ENV
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=your-app-password
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"
2
Use Mailtrap for testing
ENV
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your-mailtrap-username
MAIL_PASSWORD=your-mailtrap-password
MAIL_ENCRYPTION=tls
3
Use log driver for local development
ENV
MAIL_MAILER=log
# Emails will be written to storage/logs/laravel.log
# Great for development without sending real emails
4
Clear config cache after changes
Bash
php artisan config:clear
php artisan cache:clear
# Test mail sending
php artisan tinker
>>> Mail::raw('Test', fn($m) => $m->to('[email protected]'));
Need Help With Your Laravel Project?
I specialize in building custom Laravel applications, process automation, and SaaS development. Whether you need to eliminate repetitive tasks or build something from scratch, let's discuss your project.
About Hafiz
Senior Full Stack Developer. I build production software with Laravel, Filament, Vue, and AI integrations, and write about the real decisions behind shipping it.
Get in touch →