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. 1 Incorrect SMTP credentials
  2. 2 SMTP server not reachable
  3. 3 SSL/TLS configuration mismatch
  4. 4 Mail driver not properly configured
  5. 5 Firewall blocking outbound SMTP

Solutions

1

Configure SMTP in .env

ENV
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=your@gmail.com
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('test@example.com'));

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.

Currently available for 2-3 new projects

Hafiz Riaz

About Hafiz

Full Stack Developer from Italy. I build web applications with Laravel and Vue.js, and automate business processes. Creator of ReplyGenius, StudyLab, and other SaaS products.

View Portfolio

Related Errors