2

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
Salim Djerbouh
  • 10,719
  • 6
  • 29
  • 61
Adeel Tahir
  • 203
  • 2
  • 9
  • 1
    The command for clearing the cache is `php artisan cache:clear` . Or if you want to clear only configuration cache - `php artisan config:clear` . – ahappydev May 20 '20 at 19:15
  • what does your `config/mail.php` file look like? – patricus May 20 '20 at 19:16
  • what's the line in your code where you're sending the mail? i think this might not have anything to do with mail trap – maximus1127 May 20 '20 at 19:16
  • @ahappydev i have tried all of these cache clear things, but getting same issue. – Adeel Tahir May 20 '20 at 19:17
  • @maximus1127 this is the code i have inside my controller Mail::to("example@email.com")->send(new TestEmail($data)); For this i have created a mailable through php artisan make:mail TestEmail and by the way i have imported namespaces as well inside controller use Illuminate\Support\Facades\Mail; use App\Mail\TestEmail; – Adeel Tahir May 20 '20 at 19:22
  • What does `dd(config('mail'));` show (blank out any secret values)? – patricus May 21 '20 at 01:34

3 Answers3

5

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.

Jon
  • 2,277
  • 2
  • 23
  • 33
1

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}"
1

In my case

php artisan config:clear

Solved the issue.

Sabin Chacko
  • 713
  • 6
  • 17