php - Laravel send mail with default credentials

I'm trying to send a mail via laravel. Without Laravel it's no proplem for me using
$headers = "From: ".FROM_MAIL;
mail(TO_MAIL, "Subject", "Text", $headers);
In Laravels .env file I have to set some credentials but do I really need to do this? Because it seems to work with default credentials set anywhere in the server.
So my question is: How do I configure the .env file correctly?
If I set nothing:
MAIL_DRIVER=
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
[email protected]
MAIL_PASSWORD=
MAIL_ENCRYPTION=
MAIL_FROM_NAME="From Name"
I get the following error:Too few arguments to function Illuminate\Support\Manager::createDriver(), 0 passed in /mnt/web409/e0/11/59802411/htdocs/test/crm/vendor/laravel/framework/src/Illuminate/Support/Manager.php on line 96 and exactly 1 expected
FYI: I am using a server of Strato!
Thanks for your help!
Answer
Solution:
If you are using laravel you should actually not using mail() directly as this is a native php function
read: https://laravel.com/docs/7.x/mail
That should explain you how, you supposed to work with emails in laravel.
If you have no idea, how this email works, that probably is the case, you probably are looking to use the driver 'sendmail' which is similar to the native mail() function (https://www.php.net/manual/en/function.mail.php)
If this is a good choice, depends on your goals, requirements and server setup
Answer
Solution:
For everyone who has the same problem as me:
In the config/mail.php file 'sendmail' =>'/usr/sbin/sendmail -bs',
must be replaced by'sendmail' => '/usr/sbin/sendmail -t -i',
.
Also, the configuration must look like the one in my comment under the reply from Danny Ebbers
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: too few arguments to function laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.