Reputation: 6679
So I read the documentation and tutorials about 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.
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.
My config/mail.php
:
return array(
'driver' => 'mail',
'host' => '',
//etc I didn't change the rest
);
emails.mail view:
<!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?
Upvotes: 1
Views: 9286
Reputation: 21184
Ideally, use an SMTP service (like Mailgun, Mandrill or Amazon's SES) and configure Laravel to connect to that.
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?
Upvotes: 1