Laravel: How to send emails using sendmail

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Laravel: Enhancing Email Sending with Sendmail Driver Using Mail Facade Introduction: Laravel provides various ways to send emails within your application through its built-in mailer system. Among these drivers, the primary ones are SMTP, Mailgun, Log and Array. In this post, we will focus on using the sendemail driver, which is similar to the default php mail function but leverages Laravel's powerful Mail Facade. This can be an effective solution for some situations where other SMTP-based drivers might not work as expected or are more restrictive in terms of configuration. The Sendmail Driver Configuration: To utilize the sendemail driver, you need to define the driver and its specific setup in your .env file. Here's a working example: ```shell MAIL_DRIVER=sendmail MAIL_SENDMAIL='/usr/sbin/sendmail -t -i' ``` In this configuration, set 'MAIL_DRIVER' to 'sendemail', and specify the path of your sendmail binary along with its parameters. By default, Laravel uses '/usr/sbin/sendmail'. However, depending upon your operating system and setup, you may need to adjust this accordingly. Consult relevant documentation or search for instructions on your specific platform to ensure a seamless integration. Configuring Mail Facade in config/mail.php: The next step is setting up the default mailer in your Laravel application's config/mail.php file. You can use the following code snippet as an example: ```shell 'default' => env('MAIL_MAILER', 'sendemail'), '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', ], ], ``` This configuration allows you to use multiple mailer drivers. For example, the default configuration could be SMTP (smtp), while you can send emails using other configurations like Sendmail, Log, or Array as per your requirements. This flexibility is a notable advantage of using the Laravel's Mail Facade. Best Practices: When using the Sendmail driver, ensure that your application has the appropriate permissions for running the sendmail process. By default, this binary is installed with restricted access to prevent malicious use. If you experience issues while configuring the sendemail driver, try running 'sendmail -t -i' in a command prompt without Laravel and observe its output. This can help identify any potential errors or permissions needed. In conclusion, using the Sendmail driver with Laravel's Mail Facade is an effective way to leverage your existing mail setup while still utilizing the powerful features of Laravel. By correctly configuring your .env file and making use of available options in config/mail.php, you can ensure a seamless email sending experience across various drivers. If you need further guidance or assistance with any specific configuration or error, feel free to reach out to the Laravel community for help.