ARTICLE AD BOX
I'm using a PHP 8.2 environment. For some reason, if I try to use the php mail() function with an empty string as the fifth parameter, I get the following error:
public function testmail() { $to = '[email protected]'; $subject = 'Testmail'; $message = 'This is a test'; $headers = []; $additional_params = ''; mail($to, $subject, $message, $headers, $additional_params); } [TypeError] mail(): Argument #5 ($additional_params) must be of type string, null given in /src/Controller/UsersController.php on line 300It does seem to work on my local computer with the same PHP version, but my server does have this problem.
Now before you answer that I should just not pass the fifth argument at all since it is optional, let me add some additional context. The above is a MVP of the actual problem in my CakePHP 4.x project, using the CakePHP Mailer to send an email.
The error that occurs appears to happen in the MailTransport class, where the _mail() function calls the internal mail() function of PHP. The fifth string $additional_params = "" parameter is always passed by the `MailTransport class in case it is not null, but it defaults to an empty string if it is.
Now since this is vendor code, I do not want to alter it as an update would undo my changes. I have also already tried to explicitly pass ' ' (a space), but the error is still thrown unfortunately.
Is there anything else I could try or change about my server environment?
