Laravel5.2邮件服务不使用全局“发件人”地址的原因


laravel 5.2 mail service not using global 'from' address why?

嘿,伙计们正在配置Laravel附带的邮件服务。

这是我的mail.php file

/*
|--------------------------------------------------------------------------
| 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' => 'someguy@somehost.com', 'name' => 'Some Guy Senderl'],

这是我的.env file

APP_ENV=local
APP_DEBUG=true
APP_KEY=secret
DB_HOST=localhost
DB_DATABASE=c9
DB_USERNAME=secret
DB_PASSWORD=
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=secret@gmail.com
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls

这是我的route

Route::get('/email', function() {
    Mail::send('emails.welcome', ['name' => 'bvc'], function ($message) {
    $address = 'support@secret.com';
    $message->to('secret@gmail.com');
    $message->from($address, 'Thank you');
    $message->subject('thanks for signing up, all you need to do is confirm your email address and we are good to go');
});

我的问题是这个。
每当我发送电子邮件时,发件人仍然secret@gmail.com所以基本上我从我自己而不是$message->from($address, 'Thank you');向自己发送东西,
所以我对为什么会发生这种情况感到困惑。我确实填满了global from address,但这似乎也被覆盖了。

这不是Laravel的问题,而是SMTP问题。大多数 SMTP 主机(如 Gmail)不允许您更改"发件人"地址,或者只允许您将其更改为与您的帐户相关联并验证您拥有该地址的地址。这样做是为了减少垃圾邮件,因为您不应该能够发送电子邮件并使其看起来像来自任何人。

如果您希望能够以support@secret.com方式发送邮件,则需要将该电子邮件链接到您的secret@gmail.com帐户。在 Gmail 中,转到 Settings ,转到 Accounts and Import ,然后在 Send mail as 下,单击Add another email address you own 。完成将support@secret.com链接到您的Gmail帐户的过程后,您应该能够将发件人地址更改为该地址。