简体   繁体   English

Laravel驱动程序``邮件''未发送电子邮件

[英]Laravel driver 'mail' not sending an email

So I read the documentation and tutorials about sending mails in Laravel and I cant seem to figure out what's going wrong. 因此,我阅读了有关在Laravel中发送邮件的文档教程 ,但似乎无法弄清楚出了什么问题。 The mail is not sending yet it doesn't give me an error either. 邮件未发送,也没有给我错误。

This is the code I am using to send the mail: 这是我用来发送邮件的代码:

$data=array(
'id'=>1
'email'=>'myemail@email.com',
'name'=>'test'
);

Mail::send('emails.mail', $data, function($message) use ($data)
        {
            $message->from('test@test.com', 'me');
            $message->to($data['email'],$data['name'])->subject('id: '. $data['id'] );
        });     

Of course the 'email'=>'myemail@email.com' is replaced by my email. 当然, 'email'=>'myemail@email.com'由我的电子邮件代替。

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? 我在这里做错了什么?

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? 如果是,那么您在日志中看到了什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM