PHP 8.2 - PHP Mail Issue with Outlook Client and IW IMAP account

This is a weird one, not a huge issue and specific (that I’ve noticed) only to PHP 8.2 and Outlook…but pretty annoying. This is definitely an Outlook issue because the broken one looks fine using webmail on the server, but not sure why it works on 7.4 and not 8.2.

Only difference I notice is PHP 7.4 has the Received By / From / To / Subject… all at the top and then X-Mailer, X-Spam-Checker… at the bottom. But at the same breaking point of “on the server.url.com” it doesn’t break after that and go into body in the 7.4 email, even though there is X-Spam-Level and X-Spam-Status after that point.

Also, it works fine sending to a nonIW account to outlook, so I think it’s got something to do with the headers, maybe the X-Spam-Checker-Version where the break happens.

Here is an email from WordPress from the same site every time…
From PHP 7.4 to Outlook (to local IMAP email to server) - Looks fine
From PHP 8.2 to Outlook (to local IMAP email to server) - Broken

From PHP 7.4 to Outlook (to local IMAP email to server)

Received: (qmail 12341234 invoked by uid 000); 14 Feb 2023 13:11:48 -0500
From: "WordPress" <wordpress@somewebsite.com>
To: <justin@someemail.com>
Subject: [Wordfence Alert] somewebsite.com Admin Login
Date: Tue, 14 Feb 2023 13:11:48 -0500
Message-ID: <asdfsadfasdfasfsafd@somewebsite.com>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="utf-8"
Content-Transfer-Encoding: 7bit
X-Mailer: PHPMailer 6.6.5 (https://github.com/PHPMailer/PHPMailer)
Thread-Index: asdfsadfsadfsaf
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
	theserver.url.com
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=4.0 

From PHP 8.2 to Outlook (to local IMAP email to server)
Note, this is broken into what shows in the actual headers and what is broken and show in the body of the email.

Headers

X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on

Headers In The Body

	theserver.url.com

X-Spam-Level: 

X-Spam-Status: No, score=-1.9 required=4.0 

Received: (qmail 12345 invoked by uid 000); 14 Feb 2023 13:01:23 -0500

To: justin@someemail.com

Subject: =?us-ascii?Q?[Wordfence_Alert]_somewebsite.com_Adm?=

 =?us-ascii?Q?in_Login?=

Date: Tue, 14 Feb 2023 18:01:23 +0000

From: WordPress <wordpress@somewebsite.com>

Message-ID: <asdfsdafsaddfa@somewebsite.com>

X-Mailer: PHPMailer 6.6.5 (https://github.com/PHPMailer/PHPMailer)

MIME-Version: 1.0

Content-Type: text/plain; charset=UTF-8

I found this on PHP website.
https://bugs.php.net/bug.php?id=81158
Looks like there was a bug that went unpatched which allowed emails sent a certain wrong way without issue. They fixed the issue with PHP 8.0 and now emails sent with the wrong method are now showing as broken.

So it seems like the plugin I’m using that is sending emails from WordPress needs to be updated to fix this.


Reviewing further the plugin uses the default wp_mail which uses PHPMailer, so I grabbed the latest PHPMailer and replaced it on my WordPress install and it has the same error.

So I’m back to thinking it’s a combination something different with PHP 8.2 with headers and InterWorx mail setup with spam scan.

Hi Justec

Hope your well

I have tried this on a fresh install of WP6.1 and PHP8.2 and below is the header and body unsing contact 7 form

I think your saying part of the header details are appearing the body section, so do you mind me asking if you are forwarding the email at all

Many thanks

John

Header

X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on .co.uk
X-Spam-Level:
X-Spam-Status: No, score=0.0 required=10.0 tests=NO_RELAYS,URIBL_BLOCKED,
URIBL_DBL_BLOCKED_OPENDNS,URIBL_ZEN_BLOCKED_OPENDNS autolearn=disabled
version=3.4.2
Received: (qmail 3214 invoked by uid 1009); 15 Feb 2023 21:04:32 +0000
To: admin@
.co.uk
Subject: My Blog “test only”
Date: Wed, 15 Feb 2023 21:04:32 +0000
From: My Blog <admin@.co.uk>
Reply-To: test@test.url
Message-ID: <WhpC0tNmDFdqxqxwpZuL9wIqU3ZBR9BbUPlE7QqkcLk@
.co.uk>
X-Mailer: PHPMailer 6.6.5 (GitHub - PHPMailer/PHPMailer: The classic email sending library for PHP)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8

Body

From: test test@test.url
Subject: test only

Message Body:
test only


This e-mail was sent from a contact form on My Blog

Right, if I go to properties of the email in Outlook it shows some in the header and then the body has the rest. This also means the messages shows blank, no To, no From, No Subject because all those headers are in the body.

To keep this more simple I have narrowed my testing to using Formidable forms and it’s still happen.

The only part that stays in the header is the first line, then everything else is in the body. So in your example this is how it would display, with =-=-=-=-=-=- being the divider between header and body.

X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
            website.co.uk
X-Spam-Level:
X-Spam-Status: No, score=0.0 required=10.0 tests=NO_RELAYS,URIBL_BLOCKED,
            URIBL_DBL_BLOCKED_OPENDNS,URIBL_ZEN_BLOCKED_OPENDNS autolearn=disabled
version=3.4.2
Received: (qmail 3214 invoked by uid 1009); 15 Feb 2023 21:04:32 +0000
To: admin@</strong></em>.co.uk
Subject: My Blog “test only”
Date: Wed, 15 Feb 2023 21:04:32 +0000
From: My Blog <admin@<em><strong>.co.uk>
Reply-To: test@test.url
Message-ID: <WhpC0tNmDFdqxqxwpZuL9wIqU3ZBR9BbUPlE7QqkcLk@</strong></em>.co.uk>
X-Mailer: PHPMailer 6.6.5 ([GitHub - PHPMailer/PHPMailer: The classic email sending library for PHP](https://github.com/PHPMailer/PHPMailer))
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8

Body

From: test [test@test.url](mailto:test@test.url)
Subject: test only

Message Body:
test only

–
This e-mail was sent from a contact form on My Blog

Also, while I was typing this another alert message from a custom website I built using just the basic mail() is doing the same thing. So my guess is wp_mail using PHPMailer is at the end just using the basic local mail() from PHP and that is the problem somehow. I just can’t seem to figure out what it is.

This seems to be closely related to my issue.

Ok, the issue has to do with SpamAssasin headers.

I shutdown SA, ran my basic mail() test and the email came in fine.

So something SA is doing to the headers, along with the new mail() in PHP 8.x does something that Outlook does not like.

Hello–

I’ve been trying to reproduce this issue and so far have not been able to (Though am still trying). Part of my difficulty, though, is that my outlook client will not give me the “view source” option for messages sent from my server–other messages, that option appears, but these messages, it does not. I never use Outlook and google is failing me as to why there might be a difference, but, in the meantime, I am trying with Thunderbird, to no avail.

Is this issue only appearing in Outlook for you, or in other mail clients, as well?

Thanks,
-Jenna

The only other email client that I have tried is my iPhone. It is actually broken on there too, just not as bad. On iPhone it does show the FROM, TO, and SUBJECT, but says “This message has no content” even though there is content in the body of the test email.

On Outlook the headers break early, right after that first SA line (which is the first header line). This part stays in the header “X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on” and then the server url goes to the body and everything after that.

Using RoundCube webmail directly on the server it reads the message correctly.

I am using Outlook 2019, not 365, so not sure if it’s version specific.

Thanks, that’s useful into, though, unfortunately, I don’t have an iPhone either, and cannot reproduce on android. I am spinning up an entirely fresh server to try again, though, since my original test server was 8.0 before I updated to 8.2. So I’m going to try now with a 7.4 server and update that to 8.2.

Out of curiosity–we had someone submit a ticket for the same issue–are you a customer of Steadfast or associated with Steadfast? Just to make sure if this is an issue of two people reporting the same thing, or just a hosting company reporting something to our helpdesk that has also been reported, here by their customer.

Thanks
-Jenna

1 Like

Yeah, that’s me. I started on here and was talking to them and they opened a ticket as well.

Also, another note is this was an in place upgrade IW server 7. So not sure if that is making a difference.

Oh, and one more thing, I sent you a DM with an email account on my server and a way to generate PHP emails into that account so you could test directly from my server, with your email clients to see if you can reproduce the error that way.

For anyone reading this, thanks to Jenna spending many hours helping me debug this, she discovered I was running on the old MDA. After upgrading to Dovecot my email now looks normal on Outlook.

See this for more details:
https://appendix.interworx.com/current/nodeworx/mail_server/smtp/how-to-enable-sni-for-mail-over-port-587-and-465.html

Thanks again Jenna!