Laravel 驱动程序“邮件”不发送电子邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29230197/
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
Laravel driver 'mail' not sending an email
提问by Loko
So I read the documentationand tutorialsabout sending mails in Laravel and I cant seem to figure out what's going wrong. The mail is not sending yet it doesn't give me an error either.
因此,我阅读了有关在 Laravel 中发送邮件的文档和教程,但似乎无法弄清楚出了什么问题。邮件没有发送但它也没有给我一个错误。
This is the code I am using to send the mail:
这是我用来发送邮件的代码:
$data=array(
'id'=>1
'email'=>'[email protected]',
'name'=>'test'
);
Mail::send('emails.mail', $data, function($message) use ($data)
{
$message->from('[email protected]', 'me');
$message->to($data['email'],$data['name'])->subject('id: '. $data['id'] );
});
Of course the 'email'=>'[email protected]'
is replaced by my email.
当然'email'=>'[email protected]'
被我的电子邮件所取代。
My config/mail.php
:
我的config/mail.php
:
return array(
'driver' => 'mail',
'host' => '',
//etc I didn't change the rest
);
emails.mail view:
emails.mail 视图:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
<h2>Hello {{$name}}</h2>
<p> ID: {{$id}}</p>
</body>
</html>
I have no idea what I'm doing wrong here. The view is running just fine. What am I doing wrong here?
我不知道我在这里做错了什么。视图运行得很好。我在这里做错了什么?
采纳答案by Dan Blows
Ideally, use an SMTP service (like Mailgun, Mandrill or Amazon's SES) and configure Laravel to connect to that.
理想情况下,使用 SMTP 服务(例如 Mailgun、Mandrill 或 Amazon 的 SES)并配置 Laravel 以连接到该服务。
Email sent directly from your server often gets identified as spam, and it's also more difficult to debug, get reports, etc.
直接从您的服务器发送的电子邮件通常会被识别为垃圾邮件,而且调试、获取报告等也更加困难。
If you still want to send from the local box, is it configured to send email? If not, follow these instructions. If it is, then what do you see in your logs?
如果您仍然想从本地邮箱发送,是否配置为发送电子邮件?如果没有,请按照以下说明操作。如果是,那么您在日志中看到了什么?