I get this error with stock email settings in Laravel 5.1 Homestead when I try to send a password reset mail.
Swift_TransportException in AbstractSmtpTransp
In Laravel 7 , your .env file should be like this
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME="your username"
MAIL_PASSWORD="your password"
MAIL_ENCRYPTION=tls
#MAIL_FROM_ADDRESS=null
#MAIL_FROM_NAME="${APP_NAME}"
Make sure these two lines are commentout like this...
#MAIL_FROM_ADDRESS=null
#MAIL_FROM_NAME="${APP_NAME}"
Final step: run these step of command in your terminal to successfully send notification -
php artisan config:cache
php artisan cache:clear
php artisan config:clear
If you don't have access to the .env file, you can add default values to those env calls on app/config/mail.php, like this:
'from' => ['address' => env('MAIL_FROM_EMAIL','do_not_reply@email.com'), 'name' => env('MAIL_FROM_NAME','SpongeBob')],
This approach will try to get the data from the .env file, if there's nothing there, it'll default to whatever you set.
the problem is the null value of MAIL_FROM_ADDRESS in .env file.
solutions 1: change the value of the MAIL_FROM_ADRESS to match your email address(don t forget to rerun your server). solution 2: keep the .env file as it was but you need to change mail.php(app/config/mail.php):
'from' => [
'address' => env('MAIL_FROM_ADDRESS','mail@test.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
]
to:
'from' => [
'address' => 'mail@test.com',
'name' => env('MAIL_FROM_NAME', 'Example'),
]
go to you .env
file which is located at the root of your folder
Then set your configuration for mail like this if you are also using smpt.mailtrap.io
as MAIL_HOST.
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=******username******
MAIL_PASSWORD=******password******
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=john@example.com
MAIL_FROM_NAME="${APP_NAME}"
now to set your MAIL_USERNAME
and MAIL_PASSWORD
click here to go to mailtrap
now sign up or login if you already have an account for it.
then click Inbox then select demo inbox there you'll find the integration dropdown then select for Laravel and it will provide you with the username and password required to fulfill you .env
file.
then save the information in your .env
file for you Mail Configuration.
Now the most important part is that you run these two command line in your terminal.
run php artisan serve
again
run php artisan config:clear
Then do your process and check out the mailtrap inbox. for me it worked like this.
I have tried all the solution here but didn't work until I run this three commands
php artisan config:clear
php artisan cache:clear
php artisan config:cache
Make sure MAIL_FROM_ADDRESS in env .file is not null.
MAIL_FROM_ADDRESS=test@laravel.com
the next step you have to use these commands:
php artisan config:cache
php artisan cache:clear
I hope it was useful.