Php laravel 5.2邮件服务不使用全局';从';为什么?
嘿,伙计们,正在配置laravel附带的邮件服务 这是我的Php laravel 5.2邮件服务不使用全局';从';为什么?,php,laravel,Php,Laravel,嘿,伙计们,正在配置laravel附带的邮件服务 这是我的mail.php文件 /* |-------------------------------------------------------------------------- | Global "From" Address |-------------------------------------------------------------------------- | | You may wish for all e-mail
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' => 'someguy@somehost.com', 'name' => 'Some Guy Senderl'],
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
这是我的.env文件
/*
|--------------------------------------------------------------------------
| 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'],
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::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
所以我基本上是从我自己而不是从($address,'Thank you')向自己发送东西代码>所以我不明白为什么会这样。我确实填写了
全局发件人地址,但该地址似乎也被覆盖。这不是Laravel问题,而是SMTP问题。大多数SMTP主机(如gmail)不允许您更改“发件人”地址,或者只允许您将其更改为链接到您的帐户并验证您拥有该帐户的地址。这样做是为了减少垃圾邮件,因为你不应该发送电子邮件,让它看起来像来自任何人
如果您希望能够以support@secret.com
,您需要将该电子邮件链接到您的secret@gmail.com
帐户。在gmail中,转到设置
,转到帐户并导入
,然后在以
身份发送邮件下,单击添加您拥有的另一个电子邮件地址
。一旦完成链接support@secret.com
对于您的gmail帐户,您应该能够将发件人地址更改为它。这不是Laravel问题,而是SMTP问题。大多数SMTP主机(如gmail)不允许您更改“发件人”地址,或者只允许您将其更改为链接到您的帐户并验证您拥有该帐户的地址。这样做是为了减少垃圾邮件,因为你不应该发送电子邮件,让它看起来像来自任何人
如果您希望能够以support@secret.com
,您需要将该电子邮件链接到您的secret@gmail.com
帐户。在gmail中,转到设置
,转到帐户并导入
,然后在以
身份发送邮件下,单击添加您拥有的另一个电子邮件地址
。一旦完成链接support@secret.com
对于您的gmail帐户,您应该能够将发件人地址更改为该地址