vendredi 13 mai 2016

Laravel .env constants not working with mail.php

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire