2

In forgot password laravel sends email which gives error like :

Swift_TransportException in AbstractSmtpTransport.php line 162:

Cannot send message without a sender address

i already have set my mail account details in .env and mail.php both.

My .env :

MAIL_DRIVER=smtp
MAIL_HOST=smtp-mail.outlook.com
MAIL_PORT=587
MAIL_USERNAME=raval_himanshu@live.in
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=tls

and my mail.php is

<?php

return [   

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

'host' => env('MAIL_HOST', 'smtp-mail.outlook.com'),    

'port' => env('MAIL_PORT', 587),  

'from' => ['raval_himanshu@live.in' => null, 'Himanshu Raval' => null],

/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/

'username' => env('raval_himanshu@live.in'),



'sendmail' => '/usr/sbin/sendmail -bs',

];

i have tried php artisan config:cache too but after that it gives same error.

Tarunn
  • 1,038
  • 3
  • 23
  • 45
Himanshu Raval
  • 193
  • 1
  • 2
  • 11

5 Answers5

11

i have made mistake in mail.php

'from' => ['raval_himanshu@live.in' => null, 'Himanshu Raval' => null],

that should be

'from' => ['address' => 'raval_himanshu@live.in', 'name' => 'Himanshu Raval'],
Tarunn
  • 1,038
  • 3
  • 23
  • 45
Himanshu Raval
  • 193
  • 1
  • 2
  • 11
8

just try this code below, because this work for me in .env file

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=myAPPpassword_Generatedfromhttps://myaccount.google.com/security#signin
MAIL_ENCRYPTION=tls

in config/mail.php i change like this

 'from' => ['address' => 'myemail@gmail.com', 'name' => 'Admin.com'],//default :'from' => ['address' => null, 'name' => null],

then run the php artisan config:cache to clear configurations cache and cache again with new configurations, i hope can help

Hashan
  • 656
  • 1
  • 8
  • 20
1

Just run php artisan optimize:clear, its work for me.

STA
  • 30,729
  • 8
  • 45
  • 59
chirag
  • 11
  • 1
0

you should do it in build function in your Mail which you created example is given below

public function build()
    {
        return $this->from('example@gmail.com')->view('welcome');
    }
M Mamoon Khan
  • 169
  • 2
  • 9
0

After .env update, please restart php artisan (CTRL+C then php artisan serve)