SiL3NC3's avatar

How to setup Laravel and Laragon using sendmail.exe on windows

  • OS: Windows 10
  • Laravel Version: 8.75
  • PHP Version: 7.4.27
  • Database Driver & Version: sqlite

Description:

I trying around getting sendmail (Laragon) to work, but without luck. File '.env' got adjusted to use sendmail instead of smtp on a fresh laravel project.

Steps To Reproduce:

  • created new laravel project laravel new test
  • adjusted .env file:
MAIL_MAILER=sendmail
MAIL_SENDMAIL_PATH='C:\LARAGON\bin\sendmail\sendmail.exe -bs' 
  • run command: php artisan tinker
  • run tinker command: Mail::raw('Hello World!', function($msg) {$msg->to('[email protected]')->subject('Test Email'); });

After running the tinker command, the cmd is hanging...

Also tried different options on the sendmail flags:

  • sendmail.exe -t -i <<< tinker hangs
  • sendmail.exe -t <<< tinker hangs
  • sendmail.exe -bs <<< tinker hangs

I can see that the sendmail.exe is running (in task manager), but seems not be able to finish (waited several minutes). Cancelation (CTRL-c) will close the tinker session and the sendmail.exe ist terminated.

With other php built-in mail function Laragon is working fine and also successfully catching the sent mails in the mail folder.

I always tried to clear configuration cache after every change of the .env file. php artisan config:clear

Sending mail via php works fine as expected with the following code:

<html>
   
   <head>
      <title>Sending HTML email using PHP</title>
   </head>
   
   <body>
      
      <?php
         $to = "[email protected]";
         $subject = "This is subject";
         
         $message = "<b>This is HTML message.</b>";
         $message .= "<h1>This is headline.</h1>";
         
         $header = "From:[email protected] \r\n";
         $header .= "Cc:[email protected] \r\n";
         $header .= "MIME-Version: 1.0\r\n";
         $header .= "Content-type: text/html\r\n";
         
         $retval = mail ($to,$subject,$message,$header);
         
         if( $retval == true ) {
            echo "Message sent successfully...";
         }else {
            echo "Message could not be sent...";
         }
      ?>
      
   </body>
</html>

Any help really appreciated.

0 likes
0 replies

Please or to participate in this conversation.