Wesley
Wesley

Reputation: 45

Laravel mail failed to send mail

So for the first time I tried Laravel mailer but I encountered some problems vs the normal php mail() which just sends the mail.

My laravel code:

if(Mail::send('pages/mail', $data, function($message)
{
    $message->from('webmaster@example.com', Input::get('name'));

    $message->to('nobody@example.com')->subject('Welcome to My Laravel app!');
}))
{
    return "success";
}
else
{
    return Mail::failures();
}

My laravel error response:

"["nobody@example.com"]"

(basically the mail address I put in to().

If I use the normal php mail() it sends the mail without error (it only came into my spam folder but it was just a test).

Any idea what the problem might be?

Upvotes: 1

Views: 6295

Answers (1)

Thomas Jensen
Thomas Jensen

Reputation: 2198

Make sure you are using the correct mail driver in config/mail.php:

/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/

'driver' => 'mail',

Upvotes: 5

Related Questions