-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error sending mail: corrupt headers #24
Comments
Hi @michlann, Are you able to provide more details? I'm unable to replicate with the IMAP backend and my hunt through the code is pointing to the use of \r\n for mail. Happy to be proven wrong just not sure what I can check here to get to the bottom of it. Cheers, |
Hello @matidau, Happy to provide whatever I can to help... but not sure what indeed helps. I can show that within Z-Push, there is no problem visible. This is from WBXML debug: Incoming mail:
----------------end-log------------------------------- All good so far, nothing to see. The mail is converted to MIME and then handed over to PHP's mail(). Here is the MIME: --------------------log-------------------------------
----------------end-log------------------------------- That is still good. Also, as the log tells, the mail is saved in the Sent folder. And that copy is always intact. In other words, I don't see so far where Z-Push would be to blame, other than, maybe, the way the mail() function is called. And now the problem: here is what the mail looks like on the receiver end: --------------------log-------------------------------
----------------end-log------------------------------- Yes, that's not the exact same message, but that's not relevant. The problem is visible in the 5 lines after "MIME-Version: 1.0", where there is an additional space character (verified with hexdump). The last indented line is correct again, since the "boundary=..." is a continuation of the previous line - space is expected. So the problem resides between logs 2 and 3, and in between those is mail(). I don't have traces anymore, but I am quite sure I verified that on the first hop mailserver the spaces are already inserted. Also, it's probably easy to switch PHP back to 7.4 and verify the problem has gone. I could do that one of these days if of interest. I'm no PHP expert, so it's difficult for me to debug further. A first verification could be to check the semantics of PHP's mail(), if that changed from 7 to 8, which could potentially explain changed behaviour. Thanks anyway! |
So that was a bit of good fun tracking that down. I've replicated it and yes you were spot on it is causing problems for PHP 8.0+ If your interested this Drupal issue explains what happened between 7.4 and 8.0 pretty well https://www.drupal.org/project/drupal/issues/3270647 If you can test PR #25 and let me know if this resolves this for you. |
Hi matidau, do I get it right that your code now leaves $this->sep undefined for PHP8 and later? Could that be a problem? FWIW, the source code within Z-Push is a copy of PEAR's Mail module. Their latest version 1.5.1 has not touched this specific code at hand. In any case I just verified that my previous header mangling problem is gone with your patch. Thanks for that! |
It gets defined on this line, before the modified code block gets hold of it.
This is what caused my original confusion 😊 While we could work on incorporating the current PEAR version, I'm trying not to look at new features or bigger changes than bugs until after AS16 support. Thanks for testing, I'll merge the PR 😊 |
ACK, thanks a lot! |
Hello,
I have identified what I believe is a compatibility problem with php8, in the usage of PHP's mail() function.
I was using the IMAP backend, configured to use mail() to send messages received from clients. This used to work without problems.
Some months ago the mails created this way started to be corrupt, more precisely MIME headers were corrupted in a way that the MIME structure would be displayed as text by mail readers. Analyzing the raw mail source, it turns out some header lines had an additional space character added in front, i.e. they would not be recognised anymore by the mail reader.
Debugging Z-Push, it turns out the mails are perfectly fine until handed over to the sending function, in my case mail(). Switching to smtp method is my current workaround.
According to this discussion, the adding of spaces in front of headers seems related to changes in PHP8's mail(), potentially related to CR/LF translation.
I have not taken the time to debug this further within mail(), but as-is, Z-Push is not able to send correct mails using the mail() sending method. Hence this should be addressed one way or another.
This issue serves also to document the problem and my workaround.
Environment:
Thanks!
The text was updated successfully, but these errors were encountered: