使用 Laravel 发送邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34342823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Send mail with Laravel
提问by Swarovski
I try to send a mail with Laravel, but it doesn't work. I've tried with Mandrill, mailgun and with gmail. Mandrill returns message like "missing SPF and DKIM".
我尝试用 Laravel 发送邮件,但它不起作用。我尝试过使用 Mandrill、mailgun 和 gmail。Mandrill 返回类似“缺少 SPF 和 DKIM”的消息。
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME="my gmail adress"
MAIL_PASSWORD="my gmail password"
MAIL_ENCRYPTION=tls
MAIL_PRETEND=true
That is in my EmailController :
那是在我的 EmailController 中:
Mail::send('emails.welcome', ['name' => 'Novice'], function($message){
$message->to('f***@gmail.com', 'Fabien')->subject('Bienvenue !');
});
That is the route :
那是路线:
Route::resource('emails', 'EmailController');
How can I fix it ?
我该如何解决?
回答by Grzegorz Gajda
Change MAIL_PRETEND
to false
. This option is used to test sending mails without sending.
更改MAIL_PRETEND
为false
。此选项用于测试发送邮件而不发送。
Also, since Laravel 5.2 the option pretend
won't exists anymore.
此外,从 Laravel 5.2 开始,该选项pretend
将不再存在。
The
pretend
mail configuration option has been removed. Instead, use thelog
mail driver, which performs the same function aspretend
and logs even more information about the mail message.
该
pretend
邮件配置选项已被删除。相反,请使用log
邮件驱动程序,它执行与pretend
邮件消息相同的功能并记录有关邮件消息的更多信息。
Read more: Upgrading to 5.2, Mail & Local Development