laravellaravel-7laravel-mail

Laravel: How to send emails using sendmail


I am using Laravel 7 and I want to send an email using sendemail driver using Laravel Mail Facade because it worked when I used php mail function but I want to use the Laravel Mail Facade.

This is my .env file email configration

MAIL_DRIVER=sendmail
MAIL_SENDMAIL='/usr/sbin/sendmail -t -i'

And this is my default mail in config/mail.php

'default' => env('MAIL_MAILER', 'sendmail'),
'mailers' => [
    'smtp' => [
        'transport' => 'smtp',
        'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
        'port' => env('MAIL_PORT', 587),
        'encryption' => env('MAIL_ENCRYPTION', 'tls'),
        'username' => env('MAIL_USERNAME'),
        'password' => env('MAIL_PASSWORD'),
    ],
    'ses' => [
        'transport' => 'ses',
    ],
    'sendmail' => [
        'transport' => 'sendmail',
        'path' => '/usr/sbin/sendmail -bs',
    ],
    'log' => [
        'transport' => 'log',
        'channel' => env('MAIL_LOG_CHANNEL'),
    ],
    'array' => [
        'transport' => 'array',
    ],
],

what is the right configuration how make it work?


Solution

  • check How to send email with Laravel using sendmail? and you will get full idea.