I have an issue with mailables. Here is the part of the code I'm using for sending mail
try {
Mail::to('xxx@xxx.com', 'Troubleshooting')->queue(new ErrorReport($data));
} catch (\Exception $e) {
$this->getErrors()->add('', $e->getMessage());
return false;
}
Mailable:
public function __construct($data)
{
$this->data = $data;
}
public function build()
{
return $this
->from(env('MAIL_FROM'), env('MAIL_NAME'))
->subject($this->data['subject'])
->view('emails.error_report', [
'name' => $this->data['name'],
'email' => $this->data['email'],
'msg' => $this->data['msg'],
'user' => $this->data['user'],
]);
}
And finally, the view:
User name: {!! $name !!} <br/>
User email: {!! $email !!} <br/>
Message: {!! nl2br(e($msg)) !!} <br/>
User: <br/>
<pre>
{!! $user !!}
</pre><br/>
Session data: <br/>
<pre>
{!! var_dump(Session::all()) !!}
</pre><br/>
So the code doesn't error out, it returns me the message that everything went well but I never get the mail on my mail?
I also tried replacing queue()
with send()
. It doesn't do anything also, and it gives no error.
EDIT
If I set mail driver to 'log'
, mail gets in the Laravel log, but if it is on 'sendmnail'
nothing happens.
This is left default:
'sendmail' => '/usr/sbin/sendmail -bs',