How to configure Laravel mail php to use built-in mail function

0 votes

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?

Dec 3, 2020 in Laravel by kartik
• 37,520 points
3,235 views

1 answer to this question.

0 votes

Hello,

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

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'
answered Dec 3, 2020 by Niroj
• 82,840 points

Related Questions In Laravel

0 votes
1 answer

How to make a constant and use globally in laravel?

Hii, You can create a constants.php page in config folder ...READ MORE

answered Mar 24, 2020 in Laravel by Niroj
• 82,840 points
4,086 views
0 votes
1 answer

How to set port for php artisan.php serve in Laravel?

Hii @kartik, When we use the php artisan serve ...READ MORE

answered Mar 30, 2020 in Laravel by Niroj
• 82,840 points
17,704 views
+1 vote
1 answer

How to load blade or php content into a view via ajax/jquery in laravel?

Hello @kartik, Assuming you're using jQuery... create a route ...READ MORE

answered Apr 14, 2020 in Laravel by Niroj
• 82,840 points
28,032 views
0 votes
1 answer

How to use multiple databases in Laravel?

Hello @kartik, Laravel has inbuilt support for multiple ...READ MORE

answered Jul 30, 2020 in Laravel by Niroj
• 82,840 points
2,353 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,068 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
3,016 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,944 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,869 views
0 votes
1 answer

How to use mail() in laravel?

Hello, Laravel provides a powerful and clean API ...READ MORE

answered Mar 24, 2020 in Laravel by Niroj
• 82,840 points
958 views
0 votes
1 answer

How to use Stored Procedures in Laravel?

Hey, To create a Stored Procedure you can ...READ MORE

answered Mar 24, 2020 in Laravel by Niroj
• 82,840 points
5,018 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP