Laravel Mail Debugging/Result

10,265

There are many mail drivers to use to send email, so many ways to debug. An approach would be to set:

'driver' => env('MAIL_DRIVER', 'log'),

in config/mail.php then quickly test if logging of mail works with:

Mail::raw('Text to e-mail', function($message)
{
  $message->from('[email protected]', 'Laravel');
  $message->to('[email protected]');
});

Then depending on 3rd party services and protocol, keep iterating. For instance to use SES, one would fill in these environment keys:

MAIL_DRIVER='ses'
SES_KEY='XXX'
SES_SECRET='YYY'
SES_REGION='ZZZ'

in .env and then in config/services.php:

'ses' => [
    'key' => env('SES_KEY'),
    'secret' => env('SES_SECRET'),
    'region' => env('SES_REGION'),
],

Use php artisan tinker and test with the Mail::raw code above. Also note that AWS requires its API to be connected by HTTPS or it will not send email.

Share:
10,265
Enayet Hussain
Author by

Enayet Hussain

Updated on June 07, 2022

Comments

  • Enayet Hussain
    Enayet Hussain almost 2 years

    How can I see the result or errors from the Mail::send or queue methods in Laravel? I have used dd() on the method but I get either a 0 of which I am assuming is false to show the email failed to send. Is there any way to put it into a debug mode so I can see where the mailer is failing?