Laravel mailtrap not working on localhost

Viewed 4550

I have a Laravel 7.0 project, when I try to send email to mailtrap it gives me following error.

Swift_TransportException Unsupported sendmail command flags []. Must be one of "-bs" or "-t" but can include additional flags.

I have following in my .env file

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=MY_USERNAME
MAIL_PASSWORD=MY_PASSWORD
MAIL_FROM_ADDRESS=from@example.com
MAIL_FROM_NAME=Example
MAIL_ENCRYPTION=tls

Also tried to clear config cache, but it does not work.

php artisan config:cache
4 Answers

Be sure to restart your queue and run work again:

php artisan queue:restart

php artisan queue:work

From the docs: Since queue workers are long-lived processes, they will not notice changes to your code without being restarted. So, the simplest way to deploy an application using queue workers is to restart the workers during your deployment process.

Make sure to have the command flags in config/mail.php

'sendmail' => [
   'transport' => 'sendmail',
   'path' => '/usr/sbin/sendmail -bs', // <-- Here
],

As defined in the laravel/laravel repository here

I have same problem, try this if you are using gmail, also add MAIL_FROM_ADDRESS

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=********@gmail.com
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=*********gmail.com
MAIL_FROM_NAME="${APP_NAME}"

In my case

php artisan config:clear

Solved the issue.

Related