Whitespace breaking multipart emails
I'm using cPanel/WHM 96, CentOS 7.9.2009, PHP 8.0.7, Apache 2.4, and Exim 4.94.2.
When I send an email using the PHP mail() function in some code I wrote myself it send perfect multipart text/html emails that render correctly. When my Invision Community software sends an email it shows up as html code and the multipart boundaries aren't recognized. With the help of a nice guy over on serverfault he confirmed that the spaces I found at the start of the email headers would cause this.
Here is what my correct email headers look like:
Here's what the Invision Community emails look like. Note the single space in front of the From, Date, Auto-Submitted, and Content-Type headers:
The serverfault guy said that a space at the front of a line like that is called folding whitespace and it is interpreted to a continuation of the line above rather than a new header line. So, now that we know what the problem is, does anyone have any ideas of how to fix this? I already contacted Invision and they've never seen anything like this on any of their customers. I was looking at this
MIME-Version: 1.0
From: "Example"
List-Unsubscribe: ,
Date: Tue, 29 Jun 2021 19:22:08 +0000
X-AntiAbuse: This header was added to track abuse, please include it with any abuse reportHere's what the Invision Community emails look like. Note the single space in front of the From, Date, Auto-Submitted, and Content-Type headers:
MIME-Version: 1.0
From: =?UTF-8?B?SGVsaW9OZXQ=?=
Date: Tue, 29 Jun 2021 19:04:36 +0000
Auto-Submitted: auto-generated
Content-Type: multipart/alternative; boundary="--==_mimepart_3d7970817fa277e018f1936f5865d582"; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-Id:
The serverfault guy said that a space at the front of a line like that is called folding whitespace and it is interpreted to a continuation of the line above rather than a new header line. So, now that we know what the problem is, does anyone have any ideas of how to fix this? I already contacted Invision and they've never seen anything like this on any of their customers. I was looking at this
-
Hey there! It sounds like the homework you've done would show 100% the issue is with the software. I'm not sure how they could deny that with what you've shown. There are some details in the Exim docs about spaces with line endings, but I didn't find much for extra spaces at the beginning of a line. See section 2 here: 0 -
Thanks cPRex! Invision just keeps saying that their software sends emails just fine for thousands of other customers so it's got to be something wrong with my server. I'm obviously hesitant to try to fix their code for them because even if I managed to fix it it would probably just get overwritten each time I upgraded. The custom exim filters are a bit of a stretch. It would be much better to fix this at the source rather than writing some dirty hack to try to work around it. Also, it's kind of funny that a moderator edited my post and removed the single spaces at the beginning of the headers... 0 -
I'm the only moderator around, and I didn't edit the post. Maybe it's just showing up differently now? I definitely see the spaces on my end. 0 -
Ha! I refreshed on my end and now the spaces are gone... Oh, and the "edited by a moderator" is to change the "New Thread" banner after I've replied once. 0 -
I'm not sure why adjusting the thread banner would have changed the spacing, but I made the changes in a different way on my end and now they are appearing to stick properly, and so are the spaces. 0 -
Thanks cPRex for the reassurance that the issue was with Invision's code. I spent way too much time digging through their code over the last few days, and I'm proud to announce that I fixed their code! I changed one occurrence of PHP_EOL to "\r\n" and now it works. Since Invision is so adamant that their code is perfect I guess I'll just have to make this edit every time I do a software upgrade. I'm so relieved to have this fixed though. It was driving me nuts. Just wanted to give this thread some closure in case anyone searches and finds it. 0 -
That's great work! 0
Please sign in to leave a comment.
Comments
7 comments