Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Hectorhammett's avatar

Laravel Email not sending mail nor logging in the log file.

I'm trying to send an email using laravel, but for some reason it's not sending it. I chose the smtp driver, and it didn't work with our smtp server, so i tried the mailgun driver, which i've used in the past, and in the mailgun dashboard is not appearing either as sended or dropped.

I tried to use the log driver, and it's not outputing in the log file. So i went in a killing frenzy, and deleted ALL the mail.php file, and it still "worked", i mean, it didn't gave me any error or misconfiguration info. Here's my mail sending code:

public function testMail(){
      $sent = Mail::send('emails.cancelOrder', array('key' => 'value'), function($message)
      {
         $message->from('xxxxx@xxxx.com');
         $message->to('xxxxx@xxxx.com', 'John Smith')->subject('Welcome!');
      });

      if( ! $sent) dd("something wrong");
      dd("send");
    }
}

It's always returning the "send" string.

Any ideas?

0 likes
7 replies
frezno's avatar

@Hectorhammett - try this:

public function testMail()
{
        Mail::send('emails.cancelOrder', array('key' => 'value'), function ($message)
        {
            $message->from('xxxxx@xxxx.com');
            $message->to('xxxxx@xxxx.com', 'John Smith')->subject('Welcome!');
        });
}

your .env files shows MAIL_DRIVER=log right?

run this methode as is above and check your log file

Hectorhammett's avatar

@frezno Yeah, my env is on MAIL_DRIVER, also on the mail.phj sais:

    'driver' => env('MAIL_DRIVER', 'log'),

I tried, and still nothing. Not really sure what's going on. Still noting on the log file.

frezno's avatar

@Hectorhammett - you don't need the settin in your mail config file. That's what the .env file is for.

well, the code as provided above does work, ie the problem has to be somewhere else (in your code).
How do you call the testMail method?

Hectorhammett's avatar

I made a route :

Route::get('testMail','Common\CartController@testMail');

and i just type the url to the route. I'm sure is something else, but i'm not sure what is it.

ejdelmonico's avatar

Are you running XAMP or MAMP? If so, that's your issue. Use Homestead.

1 like
Hectorhammett's avatar

Nope, im in linux and using appache, BUT i finally think what was the error: I made it work using the Mailgun API directly, but i needed to create a model with a new database connection, and i couldn't make it work. It always said that: Database connection not configured. Until i ran the artisan comand:

php artisan cache:config

Now the changes on the database were reflected. I'm asuming that if i try to use the mail again, im gonna see some new things.

gibex's avatar

In L5.2 when using QUEUE_DRIVER=redis & MAIL_DRIVER=log emails are not recorded in log (this should have a better warning/notice)

To fix it, you need to set QUEUE_DRIVER=sync (default or remove the param from .env)

I think MAIL_DRIVER=log should bypass QUEUE_DRIVER (not sure how is in 5.3+)

1 like

Please or to participate in this conversation.