Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

485
Views
How to configure Laravel mail.php to use built-in mail function?

I need to send an email via the mail() PHP function. I've read somewhere that I have to change driver parameter in config/mail.php to sendmail.

By default, it looks like this:

'driver' => env('MAIL_DRIVER', 'smtp'),

Now, it looks like this:

'driver' => 'sendmail',

Also tried this:

'driver' => 'mail',

But still, the mail() function doesn't work. What do I need to change?

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

To do the same as mail() PHP function does, in most cases you should configure Laravel in the following way:

Use sendmail, at .env:

MAIL_DRIVER=sendmail

If you are using Larvel 7 or above

MAIL_MAILER=sendmail

Laravel 7 replaced MAIL_DRIVER by MAIL_MAILER

Host, user, password, port and encryption are not needed.

At this point, you may check if it already works, but sometimes the next step is also needed.

Set a new .env option in config/mail.php:

'sendmail' => env('MAIL_SENDMAIL', '/usr/sbin/sendmail -bs')

Set the sendmail path in .env. You can check sendmail_path at phpinfo(), but it's usually this one:

MAIL_SENDMAIL='/usr/sbin/sendmail -t -i'
about 4 years ago · Santiago Trujillo Report

0

To use the email server running on localhost, your .env file should look like this (The PHP mail function doesn't need a username or a password)

MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null

Then, update the configuration cache:

php artisan config:cache
about 4 years ago · Santiago Trujillo Report

0

You have to set your mail Configuration in .env file. Here you have to set all your mail driver and all details. Plase see this documentation https://laravel.com/docs/5.0/mail

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!