empty your log file and try again , then share with us your log .
Laravel 5 Mail(), nothing works
Hi all,
I feel like I am being a little stupid here. I'm trying to use Laravel Mail(), I've edited my app/config/mail.php file and tried everything. I've tried using Mailgun, SMTP, mail, sendmail - nothing works. No matter what I do, an email never sends.
If I return Mail::failures() the email is always there.
At the moment, I'm just doing this inside of a controller to see if it'll send:
Mail::send('emails.blank', array('key' => 'value'), function($message)
{
$message->from('xxxxx@xxxx.com');
$message->to('xxxxx@xxxx.com', 'John Smith')->subject('Welcome!');
});
Any help would be much appreciated!
@xroot - done that, it doesn't seem to be writing anything to the log files. Even when I said the driver to "log".
does debug mode is set to true ?
@xroot - yes, debug mode is on. No errors at all!
@xroot - that was just my bad typing, sorry. It does have an apostrophe in the script. I will update it. So that is not the issue
@xroot - "something wrong"
ok could you share your mail config
@xroot - I reverted back to the default mail.php seen here: https://raw.githubusercontent.com/laravel/laravel/master/config/mail.php - only I'm using "mail" as the driver, although, none of the others work either.
set driver to log and let see if it will work
@xroot - Set to "log" and still nothing!
With log you need to set pretend' => false, to pretend => true
@nolros - Tried that, too, before I even asked. I just tried again and still, nothing!
on my local machine i had also problems with the mail function.
Maybe take a look at mailgun -> http://laravel.com/docs/4.2/mail
setted up in a few minutes and works perfectly
@hostianer - I tried Mailgun, but that failed. I've tried my servers SMTP, still nothing. Even "mail" and "sendmail" don't work. None of the drivers work.
Did you set up the Mailgun Driver and it`s configuration ? What does the mailgun error log says ? ( there must be an error on mailgun )
'mailgun' => array(
'domain' => 'your-mailgun-domain',
'secret' => 'your-mailgun-key',
),
@hostianer - I've set the Mailgun configuration, yes. It doesn't make it that far, though, because Laravel's Mail class always fails.
Try hard coding it, which I think you did, but this would eleimnate swift issues
public function send( )
{
/// NOTE add in the right view
$emailData = [
'to' => 'bob@msn.com',
'from' => 'Company name',
'subject' => 'User Activation',
'body' => 'This is the body',
'view' => 'email.register'
];
return $this->mailer->queue($emailData['view'], $emailData, function ($message) use ($emailData)
{
$message->to($emailData['to'], $emailData['from'])->subject($emailData['subject']);
});
}
You can take a look at Mandrill as well. Works perfectly :D https://laracasts.com/lessons/laravel-and-mandrill-in-minutes
@nolros - this did not work either I'm afraid :( This is the strangest issue!
@ddotgrass Did you ever find a solution to this? I'm struggling with the same issue now, although with a Mandrill service.
I just had a similar issue with L5.1 - nothing would send, but no error messages in the log.
It turned out to be the "from" setting in the mail.php config file. That setting has "null" set for both the from email and the from name. If either are null, then an email is not sent. You may set these in the mail.php config file, and you may override them in the Mail:send() command, but you must make sure both are set and not null.
@ddotgrass Did you manage to fix it? I'm having the same problem here. Tried the suggested fixes and got nothing.
I had this problem too, i did what @consil did and it worked for me.
If the application does not crash, it means that the problem is something related with the net. But maybe, actually works. Check your spam folder inbox. Maybe there are lots of your mails.
Same problem here, only solution if found so far was to remove the from header
// $message->from('[email protected]');
try
{
Mail::send('emails.blank', ['key' => 'value'], function($message)
{
$message->from('[email protected]');
$message->to('[email protected]', 'John Smith')->subject('Welcome!');
});
} catch (\Swift_TransportException $e) {
dd($e->getMessage());
}
I had the same problem. When using a fake "from", it failed.
Therefore ensure you have that email on the server - that you are using it at "from".
Please or to participate in this conversation.