Mail function and php version

I recently switched from php 7.4. to php 8.0 (with KB version 1.2.23). I use a shared hosting from Host-Europe. When I use the “Send task by email” function, I get an email where the text contains raw HTML that is not parsed.

I found out that the email header contains the FROM: and DATE: twice, e.g.

To: "forname surname " <user@domain.tld>
Subject: TEST
Message-ID: <f7f5a1cc4545ae2c2a88a73f6edf0cf4@assets.domain.tld>
Date: Fri, 09 Sep 2022 12:15:57 +0200
From: via Kanboard <noreply@domain.tld>
Reply-To: user@domain.tld
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Auto-Submitted: auto-generated
From: noreply@domain.tld
Date: Fri, 09 Sep 2022 12:15:57 +0200

When I switch the php version back, everything is fine. Does anyone know the problem?

Steff

I found out that some header entries (Date:, From:, Reply-To:, MIME-Version:, Content-Type:, Content-Transfer-Encoding:) have a space character at the first column and this cause the problem.

To: "forname surname " <mailaddress>
Subject: TEST
Message-ID: <messageID>
:warning:Date: Fri, 09 Sep 2022 12:15:57 +0200
:warning:From: via Kanboard <mailaddress>
:warning:Reply-To: user@domain.tld
:warning:MIME-Version: 1.0
:warning:Content-Type: text/html; charset=utf-8
:warning:Content-Transfer-Encoding: quoted-printable
Auto-Submitted: auto-generated
From: noreply@domain.tld
Date: Fri, 09 Sep 2022 12:15:57 +0200

Where is the header generated?

1 Like

Problem solved: the PHP constant PHP_EOL has changed between php 7.4. and php 8.x.

kanboard-1.2.23/libs/swiftmailer/classes/Swift/Transport/MailTransport.php
162         if ("\r\n" != PHP_EOL) {
163             // Non-windows (not using SMTP)
164             $headers = str_replace("\r\n", PHP_EOL, $headers);
165             $subject = str_replace("\r\n", PHP_EOL, $subject);
166             $body = str_replace("\r\n", PHP_EOL, $body);
167             $to = str_replace("\r\n", PHP_EOL, $to);
168         } else {

changed to

162         if ("\r\n" != PHP_EOL) {
163             // Non-windows (not using SMTP)
164             $headers = str_replace("\r\n", "\r\n", $headers);
165             $subject = str_replace("\r\n", "\r\n", $subject);
166             $body = str_replace("\r\n", "\r\n", $body);
167             $to = str_replace("\r\n", "\r\n", $to);
168         } else {

Now, the mails will be parsed. This ist as swiftmailer problem, btw. this class marked as deprecated.

2 Likes