2

I use Windows 10, Laragon and Laravel Framework.

And I setup the default Auth by calling php artisan make:auth

The problem is when I try to use the Forgot Password component, the 'sendmail' does not work. After I click Send Password Reset Link, nothing happened. And the Password Reset Link does not sent to the Laragon's Mail Catcher.

This is the configuration inside .env

MAIL_DRIVER=sendmail
MAIL_SENDMAIL="C:\laragon\bin\sendmail\sendmail.exe -bs"

And this is inside config/mail.php

'sendmail' => env('MAIL_SENDMAIL', '/usr/sbin/sendmail -bs'),
Syamsoul Azrien
  • 2,534
  • 4
  • 32
  • 55
  • I added a more detailed question on this, because this is a possible Laravel bug, were I need some feedback from you guys, testing this on a other machine. https://stackoverflow.com/questions/71212826/laravel-sending-mail-not-working-tinker-hanging-when-trying-to-use-sendmail-v – SiL3NC3 Feb 21 '22 at 20:47

2 Answers2

1

Firstly, I was using custom username and password I got from my Cpanel hosting email account to setup laravel mail. It did not go through via the sendmail config or smtp config.

Reading up the doc i noticed laravel does extend the swift mailer class. I made my twick thus.

$user = User::find(1);
      $text = (new WelcomeEmail($user))->render();

        // Create the Transport
        $transport = (new \Swift_SmtpTransport(env('MAIL_HOST'), 25))
          ->setUsername(env('MAIL_USERNAME'))
          ->setPassword(env('MAIL_PASSWORD'))
        ;

        // Create the Mailer using your created Transport RFCValidation
        $mailer = new \Swift_Mailer($transport);

        // Create a message
        $message = (new \Swift_Message('Happy to Have You Onboard'))
          ->setFrom([env('MAIL_FROM_ADDRESS') => env('MAIL_FROM_NAME')])
          ->setTo(['miracle@yahoo.com'])
          ->setBody($text , 'text/html')
          ;
          $message->setReadReceiptTo(env('MAIL_FROM_ADDRESS'));



        // Send the message
        $result = $mailer->send($message);

Now the

"new WelcomeEmail"

is a Laravel mailable that bundles the view for the mail. You can brilliantly create your own mail class out of this above code to make your code tiny and extendable.

Miracool
  • 657
  • 6
  • 7
0

I would suggest not to edit config/mail.php - making use of .env file should be doing the job.

In file 'config/mail.php' you can find the code, how the sendmail path is being structured by default:

'sendmail' => [
    'transport' => 'sendmail',
    'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'),
],

Possibly in case of different Laravel versions, it could also just be a typo, so try with changed name MAIL_SENDMAIL to MAIL_SENDMAIL_PATH.

But to be honest, I was also not able to get sendmail working with Laragon's executable. If someone had success, please share your solution.

SiL3NC3
  • 690
  • 6
  • 29
  • Also have this issue, page is not rendering and in endless processing state... A solution will be really appreciated. – SiL3NC3 Feb 21 '22 at 17:29