Ad

Laravel Mail Works For One But Not There Other

- 1 answer

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('[email protected]****.nl', 'Secretaris ****')->subject('Contactform: '. Input::get('name'));
});

The $input variable is simply:

$input = Input::all();

Then the view looks like this:

<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('[email protected]****.nl', 'No-Reply ****');
    $m->to('[email protected]****.nl', 'Secretaris ****')->subject('Registration of ' . ucfirst(Input::get('firstname')) . ' as Register-member');
});

The $data value here is:

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

With the view:

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

</body>
</html>

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

[
"[email protected]****.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!

Thanks

Ad

Answer

  • I suspect the error is in this line

$m->from('[email protected]****.nl', 'No-Reply ****');

  • Please check if you can sent out an email via this email through Laravel

[email protected]****.nl

  • Check to see if you configure it properly in .env file
Ad
source: stackoverflow.com
Ad