1

I have a XAMP stack with a laravel 5.8 application running in localhost.

I am trying to send mails from application and want to use the default PHP mail function. I am assuming this does not need a SMTP server to send mails.

I have followed laravel documentation and this SO post How to configure Laravel mail.php to use built-in mail function?.

I have configured the sendmail as below

MAIL_DRIVER=sendmail
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null 
MAIL_SENDMAIL='/usr/sbin/sendmail -t -i'

Below is my code

  try {
    $users = \DB::select('SELECT * from laravel.users where DATEDIFF(end_date,CURRENT_DATE) > 10');
    foreach($users as $user){
        echo "\n $user->name";
    }
    \Mail::send('emails.reminder', ['users' => $users], function ($m) use ($user) {
        $m->from('saurav.sarkar@mycompany.com', 'Your Monthly report');

        $m->to('saurav.sarkar1@gmail.com')->subject('Your Reminder!');
    });
}
catch (Exception $e){
    echo 'Message: ' . $e->getMessage();
}
}

I can see that there are no runtime errors in my code but i don't get the mails consistently in in my inbox. The echo statement above the mail code is printed properly.

My emails.reminder blade template is a very basic view code.

I have seen the mails coming once but don't see it coming now. So, it has been quite an inconsistent behaviour.

Best Regards,

Saurav

saurav
  • 5,388
  • 10
  • 56
  • 101
  • You cannot use `sendmail` in a local environment. Check https://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost to see how to get this working – Rehmat Aug 17 '19 at 11:56
  • sendmail means whatever MTA is running (same as the plain old `mail()` function). – mario Aug 17 '19 at 11:59
  • @mario that means it should work ?...saurav.sarkar@mycompany.com is a valid mail id running server by outlook exchange server – saurav Aug 17 '19 at 12:02
  • @nakov where is the sendmail dashboard ? – saurav Aug 17 '19 at 12:03

0 Answers0