2017-08-11 128 views
0

我已经在config/mail.php中设置了从地址。但在邮件中,地址是smtp用户名。有可能在不更改smtp凭证的情况下更改发件人地址。laravel 5.4更改“从地址”而不更改smtp用户名

+0

https://laravel.com/docs/5.3/mail#configuring-the-sender – aynber

+0

我已经根据文档进行更改,因为您发送上述链接。但它从地址采取smtp用户名。 –

+1

如果您通过Gmail发送邮件,它们会覆盖发件人。其他主要提供者可能也会做类似的事你可以设置一个'Reply-To'头,或者通过一个不同的提供者来发送,比如Sendgrid。 – ceejayoz

回答

1

.ENV文件

MAIL_DRIVER=smtp 
MAIL_HOST=HOST_NAME 
MAIL_PORT=PORT 
MAIL_USERNAME=USERNAME 
MAIL_PASSWORD=PASSWORD 
MAIL_FROM_ADDRESS=FROM_EMAIL_ADDRESS 
MAIL_FROM_NAME=YOUR_NAME 

配置/ mail.php

/* 
|-------------------------------------------------------------------------- 
| Global "From" Address 
|-------------------------------------------------------------------------- 
| 
| You may wish for all e-mails sent by your application to be sent from 
| the same address. Here, you may specify a name and address that is 
| used globally for all e-mails that are sent by your application. 
| 
*/ 

// 'from' => ['address' => null, 'name' => null], 
'from' => [ 
    'address' => env('MAIL_FROM_ADDRESS', null), 
    'name' => env('MAIL_FROM_NAME', null) 
], 
0

你应该试试这个:在配置/

仅仅只改变mail.php从阵列状

'from' => [ 
    'address' => env('MAIL_FROM_ADDRESS', null), 
    'name' => env('MAIL_FROM_NAME', null) 
], 

清除缓存后并尝试:

php artisan cache:clear 
php artisan config:cache 
php artisan cache:clear 

希望为你工作!!!