嘿伙计们配置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
,但似乎也被覆盖了。
答案 0 :(得分:0)
这不是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帐户的过程后,您应该可以将发件人地址更改为该帐户。