You may need to debug email sending in you Laravel app, here are few tips you can use (Laravel 6.*).
Writing mails to log
You can write emails to log instead of sending them. Open your .env file in root folder of Laravel app and change MAIL_DRIVER variable value to log. Update your app configuration using php artisan config:cache. Now you can see your mails in ../storage/logs/ folder.
Debug SMTP messages in Laravel 6
Laravel 6 uses Swift Mailler library (not supported now) to send emails. If you want to get logs of sended messages – try this:
Add this lines to your controller before controller’s class
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail;
Add this to your controller’s method
$content = 'Test'; $title = 'Test now()= ' . date("Y-m-d",time()); $logger = new \Swift_Plugins_Loggers_ArrayLogger(); Mail::getSwiftMailer()->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger)); Mail::send('emails.test-mail-template', ['title' => $title, 'content' => $content], function ($message){ $message->from('[email protected]'); $message->to('[email protected]'); }); Log::info($logger->dump());
Create view that would be used to create email – inside ../resources/views/ folder create new folder emails and place test-mail-template.blade.php with some html in it.
Try to send email, you should find SMTP log in you ../storage/logs/ folder.