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

标签 php laravel laravel-5.2 swiftmailer

在忘记密码的情况下,laravel 发送的电子邮件会给出如下错误:

Swift_TransportException in AbstractSmtpTransport.php line 162:

没有发件人地址无法发送消息

我已经在 .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

我的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',

];

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

最佳答案

我在 mail.php 中出错了

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

应该是

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

关于php - 无法在 laravel 5.2 中发送没有发件人地址的消息 我已经设置了 .env 和 mail.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34873613/

相关文章:

json - Laravel:在 Eloquent 中解码 JSON

php - 如何创建 Laravel Eloquent 实体的空实例

php - PHP 函数 error_log() 使用安全吗?

php - 根据另一个表的条件获取连接表的行数

php - 在 php 中使用正则表达式删除 span 标签

laravel - 如何为特定表中的特定字段设置唯一性?

laravel - 在 Laravel 5.2 中工作的查询在 Laravel 5.3 中给我错误

php - if 语句中存在多个 has_term

android - Laravel + Google Cloud Messaging(连接超时)

php - Laravel:更改函数名称时 belongsTo 不起作用