php – Laravel Mail to Log-ThrowExceptions

Exception or error:

I have my Laravel Mail driver setup as to print to my log file:

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

When I send mail, however, I am receiving a swiftmail authentication error:

Expected response code 250 but got code ‘530’ with message ‘530 5.7.1
Authentication required’

vendor\\swiftmailer\\swiftmailer\\lib\\classes\\Swift\\Transport\\AbstractSmtpTransport.php

line 383\”>AbstractSmtpTransport.php line 383

530 5.7.1 Authentication required

Is there another setting I need to set somewhere? Why is it trying to use swiftmailer?

How to solve:

This is in your Mail.php config file…

When using

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

This will get the MAIL_DRIVER environment variable set in your .env file. In this case, ‘log’ is used only as a default if a value is not specified in your .env file… Your .env file probably has this still set in it… set it to log…

MAIL_DRIVER=smtp

replace with

MAIL_DRIVER=log

Answer:

If anyone encounters this error on L5.8 even after setting your mail driver to ‘log’ in the env file.

Swift_TransportException (530) Expected response code 250 but got code
“530”, with message “530 5.7.1 Authentication required “

You need to restart your web server, and restart “php artisan serve” as well.
If it still doesn’t work, you need to clear the configuration cache with php artisan config:clear

Answer:

Laravel use .ENV file!

Maybe your edit config\mail.php, try to make edits in the ENV file

Make dump the variable with your current mail configuration

Put this code in your controller

dd(config('mail'));

You will see the current settings that the system uses.

Answer:

One more reason why your MAIL_DRIVER=log configuration may not be working as expected is that you have your QUEUE_DRIVER set to something other than sync.

Thanks to the tip by gibex on Laracasts.

Leave a Reply

Your email address will not be published. Required fields are marked *