使用 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:49:26  来源:igfitidea点击:

Send mail with Laravel

phpemaillaravelspfdkim

提问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_PRETENDto false. This option is used to test sending mails without sending.

更改MAIL_PRETENDfalse。此选项用于测试发送邮件而不发送。

Also, since Laravel 5.2 the option pretendwon't exists anymore.

此外,从 Laravel 5.2 开始,该选项pretend将不再存在。

The pretendmail configuration option has been removed. Instead, use the logmail driver, which performs the same function as pretendand logs even more information about the mail message.

pretend邮件配置选项已被删除。相反,请使用log邮件驱动程序,它执行与pretend邮件消息相同的功能并记录有关邮件消息的更多信息。

Read more: Upgrading to 5.2, Mail & Local Development

阅读更多:升级到 5.2邮件和本地开发