本文介绍了Laravel Mail适用于一个,但不适用于其他的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于该网站,我有一个联系表,该表仅发送如下电子邮件:

For this website I have a contact form, which simply sends a mail like this:

Mail::send('emails.contact', $input, function ($m) {
    $m->from(Input::get('email'), Input::get('name'));
    $m->to('secretaris@****.nl', 'Secretaris ****')->subject('Contactform: '. Input::get('name'));
});

$ input变量很简单:

The $input variable is simply:

$input = Input::all();

然后视图如下所示:

<html>
<body>

<b>{{$name}} ({{$mail}}) sent u a message via the contactform on ****.nl</b>
<br>
<div>
{{$message}}
</div>
<br>

</body>
</html>

确实发送了此邮件.但这不知何故:

This mail does send. But this one somehow doesn't:

Mail::send('emails.registermember', $data, function ($m) {
    $m->from('no-reply@****.nl', 'No-Reply ****');
    $m->to('secretaris@****.nl', 'Secretaris ****')->subject('Registration of ' . ucfirst(Input::get('firstname')) . ' as Register-member');
});

此处的$ data值为:

The $data value here is:

$data = [
    'naam' => ucfirst($user->voornaam) . ' ' . ucfirst($user->achternaam),
    'id' => $user->id,
];

视图:

<html>
<body>
<p>
    <b>{{$name}}</b> registered as register member at website of ****.
</p>

</body>
</html>

此邮件不发送,而Mail :: failures()返回:

This mail does not send and doing Mail::failures() returns:

[
"secretaris@****.nl",
]

我看不出这些邮件功能有什么区别,为什么一个起作用而另一个却不起作用.

I don't see what's the difference between those mail functions, and why one works and the other doesn't.

出于隐私方面的考虑,我在网站名称上标记了****

For privacy reasons I marked the website name with ****

我希望有人能帮助我!

I hope someone can help me out!

谢谢

推荐答案

  • 我怀疑该行中的错误
  • $m->from('no-reply@****.nl', 'No-Reply ****');

    • 请检查您是否可以通过Laravel通过此电子邮件发送电子邮件

    no-reply@****.nl

    • 检查是否在.env文件中正确配置了它
    • Check to see if you configure it properly in .env file

    这篇关于Laravel Mail适用于一个,但不适用于其他的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 19:16