The error:
In my mail.php file, if I set
'driver' => env('MAIL_DRIVER'),
and have this to my .env file:
MAIL_DRIVER=log
Then I get the following error:
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "530",
with message "530 5.7.1 Authentication required"
The wonky work-around
In my mail.php file, I have the following:
'driver' => 'log',
works fine.
The Conclusion
My theory is that mail.php is not reading my .env file constant correctly, since replacing it with the actual string fixes the problem. However, the defaults for this file all make use of .env constants, so I'm wondering why are my .env constants not getting recognized in my mail.php file?
FYI
In other files besides mail.php in the same app, I am using other .env constants that work just fine. For instance, in my UserTableSeeder class, I have:
factory(App\User::class, 1)->create([
'email' => env('ADMIN_EMAIL'),
'password' => Hash::make(env('ADMIN_PASSWORD')),
'is_admin' => 1
]);
which successfully makes use of the below constants from my .env file:
ADMIN_EMAIL=xxxxxxx@yahoo.com
ADMIN_PASSWORD=xxxxxxx
I tried the below 2 php artisan commands (php artisan cache:clear and php artisan config:clear), but "smtp" continued to output when "log" is what I have in my .env file:
04:52:54 Fri May 13 vagrant@homestead (email_notifications) [130]
~/Code/myapp $ php artisan config:clear
Configuration cache cleared!
05:52:56 Fri May 13 vagrant@homestead (email_notifications) [0]
~/Code/myapp $ php artisan tinker
Psy Shell v0.6.1 (PHP 7.0.2-4+deb.sury.org~trusty+1 — cli) by Justin Hileman
>>> dd(env('MAIL_DRIVER'));
"smtp"
>>> exit
Exit: Goodbye.
05:53:23 Fri May 13 vagrant@homestead (email_notifications) [0]
~/Code/myapp $ php artisan cache:clear
Application cache cleared!
05:53:48 Fri May 13 vagrant@homestead (email_notifications) [0]
~/Code/myapp $ php artisan tinker
Psy Shell v0.6.1 (PHP 7.0.2-4+deb.sury.org~trusty+1 — cli) by Justin Hileman
>>> dd(env('MAIL_DRIVER'));
"smtp"
There might be default constants in the .env file that includes one for MAIL_DRIVER=sftp
. If you add additional values for the same constant, the FIRST constant is the one that will get defined. Thus, make sure to have just 1 constant definition in your .env file, or at least have it be the 1st one if for some reason you want more than one constant in there.