在laravel 5.2中无法发送没有发件人地址的邮件我已经设置了.env和mail.php

Him*_*val -1 php swiftmailer laravel laravel-5.2

在忘记密码laravel发送电子邮件,给出错误,如:

Swift_TransportException in AbstractSmtpTransport.php line 162:
Run Code Online (Sandbox Code Playgroud)

没有发件人地址时无法发送邮件

我已经设定在我的邮件帐户的详细信息.envmail.php两种.

我的.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
Run Code Online (Sandbox Code Playgroud)

和我的mail.php是

<?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',

];
Run Code Online (Sandbox Code Playgroud)

我也试过,php artisan config:cache但之后它也给出了同样的错误.

小智 8

只需尝试下面的代码,因为这在.env文件中对我有用

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
Run Code Online (Sandbox Code Playgroud)

config/mail.php我像这样改变

 'from' => ['address' => 'myemail@gmail.com', 'name' => 'Admin.com'],//default :'from' => ['address' => null, 'name' => null],
Run Code Online (Sandbox Code Playgroud)

然后运行php artisan config:cache以清除配置缓存并使用新配置再次缓存,我希望可以提供帮助


Him*_*val 7

我犯了错误 mail.php

'from' => ['raval_himanshu@live.in' => null, 'Himanshu Raval' => null],
Run Code Online (Sandbox Code Playgroud)

那应该是

'from' => ['address' => 'raval_himanshu@live.in', 'name' => 'Himanshu Raval'],
Run Code Online (Sandbox Code Playgroud)