PHP - Send Mail - Is it compatible with php8?

Hi Guys

PHP - Send Mail ? Compatible with php 8?
My host has send me a mail to say they upgrading to php 8 in the next couple of days.

So i set the server to php 8 to check the compatibility.
I test the “send mail” in php 7.4 and I get the mail rendered 100% when it arrives in Outlook.

So then the next step is to change the server config to php 8.
So its all sending… but when it arrives … it does not show as HTML.

Comes out as “This is a multi-part message in MIME format.”


I have checked the server setting in the send mail, and all seems good.

I have even made sure I have the latest dmxConnectLib folder


So the problem comes in if I switch to php 8

Is this some setting at the HOST that they must change… or something i can do to get the mails to render as “HTML” in php8. In php 7.3 and 7.4 seems fine…

… weird … ok seems like im the only one using php 8 since its been out … wow! … guess everybody just went back to php 7.4,

credit is due to this post for solving it


But after a few hours of searching last night… i got the answer.

I updated the PHPMAILER script, and its working on both 7.4 and 8 i can confirm my side.

Line 856 PHPmailer where the function starts. I added. Just above the results!
We added

$header = str_replace("\n", "\r\n", $header);

so that the script works like this…

private function mailPassthru($to, $subject, $body, $header, $params)
    //Check overloading of mail function to avoid double-encoding
    if (ini_get('mbstring.func_overload') & 1) {
        $subject = $this->secureHeader($subject);
    } else {
        $subject = $this->encodeHeader($this->secureHeader($subject));
    //Calling mail() with null params breaks
    if (!$this->UseSendmailOptions || null === $params) {
		$header = str_replace("\n", "\r\n", $header);
        $result = @mail($to, $subject, $body, $header);
    } else {
		$header = str_replace("\n", "\r\n", $header);
        $result = @mail($to, $subject, $body, $header, $params);

    return $result;

Its working on my side now… but please can @patrick confirm if this is OK…

Will update to latest PHPMailer, it seems to be fixed there.

This has been fixed in Wappler 4.3.0

1 Like

This topic was automatically closed after 3 days. New replies are no longer allowed.