Friendica 2022.10 seems to be sending malformed email notifications


@Friendica Support
I am the system administrator of the Friendica node at talkabout.cf, and have just updated the node to version 2022.10, along with a system upgrade to Ubuntu 22.04 and an updated web control panel. I just received several email notifications that were garbled in my inbox. I was able to trace the problem to some header lines that have an extra space at the beginning of each line. I am including these redacted headers below. I also leave a couple of lines above and below intact to make these extra leading spaces visible.
Subject: [Friendica:Notify] Name Redacted tagged you (kyle@talkabout.cf)
Precedence: list
 X-Friendica-Host: talkabout.cf
 X-Friendica-Platform: Friendica
 X-Friendica-Version: 2022.10
 List-ID: <notification.talkabout.cf>
 List-Archive: <https://talkabout.cf/notifications/system>
 X-Friendica-Account: <kyle@talkabout.cf>
 References: <RedactedHexID@email.server>
 In-Reply-To: <RedactedHexID@email.server>
 From: Talkabout Federated Social Network | Powered by Friendica <notify@talkabout.cf>
 Reply-To: Talkabout Federated Social Network | Powered by Friendica <notify@talkabout.cf>
 MIME-Version: 1.0
 Content-Type: multipart/alternative; boundary="2-189687198-581818022=:18767"
Message-Id: <RedactedMessageIDSuppliedByServer@email.server>
From: "redacted@email.address" <notify@talkabout.cf>
Date: Sun, 06 Nov 2022 14:33:24 +0100

The message ID of course is added by the mail transfer agent before the message is delivered, but I left that header because it is immediately above the Subject: header, which does not contain a leading space. I did resend the message by copying and pasting the garbled source message into a text editor, removing the leading space from each line and copying and pasting it back into a direct connection to my local SMTP server, sending the message to myself, and I received the correctly decoded message. Did I find a bug in the latest 2022.10 Friendica code, or did something go wrong with the upgrades that I performed prior to the update that somehow didn't affect anything other than these mail headers?
in reply to Kyle 🎙 🎶

Thank you for the report. These headers are handled by the third-party library that we are using, PHPMailer. We've been using it for several years now, and you are the first one to report garbled emails so I'm not sure what to say. We don't have direct control over the output and we don't have any insight about your own system. As a result there's little we can do to troubleshoot and potentially fix this issue on either end.

It sounds like there's an overly zealous mail software somewhere as no other admin has had this issue before and we haven't changed the sending software.

in reply to Hypolite Petovan

Unfortunately I think it may be non-trivial to replace Exim with Postfix on this server, as it is currently running several production mail accounts across multiple domains.

Incidentally, I used the interactive php shell to send one such garbled message back through the php mail function after rewriting the message body to escape the new line characters and rewriting the headers to remove leading spaces and add \r\n to the end of each line as I read in a guide on how to use the function. The message came to my inbox legible and ungarbled. I used the message I'm replying to here, which is already on the public forum, so I won't have to redact anything other than my own email address and my mail server domain. In case it helps, this is how I called the function.

$ php -a
php > mail ('redacted@mail.address', 'Testing php mail', "--9-424522331-136230018=:85663\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: base64\n\nSHlwb2xpdGUgUGV0b3ZhbiByZXBsaWVkIHRvIHlvdSBvbiAiVGhhbmtzIHZlcnkgbXVjaCBmb3Ig\ndGhlIGhlbHAgc28gZmFyLiBJZiBJIGRvbid0IHVzZSB0aGUgYWRkb24sIHdoaeKApiIKCiJJ4oCZ\ndmUgdGhvcm91Z2hseSBjaGVja2VkIHRoZSBjb3JlIGNvZGUgYW5kIEkgY2FuIGNvbmZpcm0gd2Ug\nZG9u4oCZdCBhZOKApiIKCknigJl2ZSB0aG9yb3VnaGx5IGNoZWNrZWQgdGhlIGNvcmUgY29kZSBh\nbmQgSSBjYW4gY29uZmlybSB3ZSBkb27igJl0IGFkZCB0aGUgbGVhZGluZyBzcGFjZS4gSG93ZXZl\nciwgYWxsIHRoZSBoZWFkZXJzIHRoYXQgc2hvdyB3aXRoIGEgc3BhY2Ugd2VyZSBzdXBwbGllZCBh\ncyBwYXJ0IG9mIHRoZSBQSFAgbWFpbCgpIGNhbGwgaW4gRnJpZW5kaWNhLCBzbyBJIGZlZWwgbGlr\nZSBpdCBoYXMgdG8gZG8gd2l0aCBFeGltLiBXb3VsZCB5b3UgYmUgYWJsZSB0byB0ZW1wb3Jhcmls\neSBzd2l0Y2ggdG8gUG9zdGZpeCB0byBwZXJmb3JtIGEgdGVzdD8KClBsZWFzZSB2aXNpdCBodHRw\nczovL3RhbGthYm91dC5jZiB0byB2aWV3IG9yIHJlcGx5IHRvIHRoZSBjb252ZXJzYXRpb24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kaWNhPC9hPiB0byB2aWV3IG9yIHJlcGx5IHRvIHRo\nZSBjb252ZXJzYXRpb24uCgkJCTwvdGQ+CgkJPC90cj4KCQk8dHI+CgkJCTx0ZCBjb2xzcGFuPSIy\nIiBzdHlsZT0icGFkZGluZy1ib3R0b206MTFweDsiPgoJCQkJPGEgaHJlZj0iaHR0cHM6Ly90YWxr\nYWJvdXQuY2Yvbm90aWZ5LzE3OCI+aHR0cHM6Ly90YWxrYWJvdXQuY2Yvbm90aWZ5LzE3ODwvYT4K\nCQkJPC90ZD4KCQk8L3RyPgoJCTx0cj4KCQkJPHRkPjwvdGQ+CgkJCTx0ZD4KCQkJCXRoYW5rcwoJ\nCQk8L3RkPgoJCTwvdHI+CgkJPHRyPgoJCQk8dGQ+PC90ZD4KCQkJPHRkPgoJCQkJVGFsa2Fib3V0\nIEZlZGVyYXRlZCBTb2NpYWwgTmV0d29yayB8IFBvd2VyZWQgYnkgRnJpZW5kaWNhIEFkbWluaXN0\ncmF0b3IKCQkJPC90ZD4KCQk8L3RyPgoJPC90Zm9vdD4KPC90YWJsZT4KCgkJCTwvdGQ+CgkJPC90\ncj4KCTwvdGJvZHk+Cgk8L3RhYmxlPgo8L2JvZHk+CjwvaHRtbD4K\n\n--9-424522331-136230018=:85663--\n\n", "Precedence: list\r\nX-Friendica-Host: talkabout.cf\r\nX-Friendica-Platform: Friendica\r\nX-Friendica-Version: 2022.10\r\nList-ID: <notification.talkabout.cf>\r\nList-Archive: <https://talkabout.cf/notifications/system>\r\nX-Friendica-Account: <kyle@talkabout.cf>\r\nReferences: <c162020a-4763-688c-b552-6bb105124076@redacted.mail.server>\r\nIn-Reply-To: <c162020a-4763-688c-b552-6bb105124076@redacted.mail.server>\r\nFrom: Talkabout Federated Social Network | Powered by Friendica <notify@talkabout.cf>\r\nReply-To: Talkabout Federated Social Network | Powered by Friendica <notify@talkabout.cf>\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=\"9-424522331-136230018=:85663\"\r\nFrom: \"redacted@mail.domain\" <notify@talkabout.cf>");
in reply to Kyle 🎙 🎶

I haven't a resolution to this but my setup is similar. I am not using phpmailer addon thus using php's builtin mail function for sending out emails. php uses sendmail binary on my system, that's msmtp which in turn uses local instance of haraka smtp server.
Email messages that I am getting into my inbox don't suffer from this.
I can't think of how exim would garble the headers though.

Friendica Support reshared this.

in reply to Peter Vágner

Thanks for the suggestion. I didn't suspect any of my enabled addons to be the cause of the problem, but disabling them and reenabling them one at a time is a troubleshooting step that I missed in the process of trying to find out what is going on. I just saw the indented headers, unindented them and resent the message and found it cleared up, so I thought it was traceable to the mailer at that point. Thanks for pointing out the addons. I'll report back here if I find anything, and I will be stumped even further if I find the same problem after disabling everything.

Friendica Support reshared this.

in reply to Kyle 🎙 🎶

I disabled every addon, even backed up my configuration, deleted all the files in my site directory and untarred the archives again. I am currently writing this post with all addons disabled, and a clean site directory, save my config/local.config.php and the database I set there. At this point, I have done everything short of trashing the database and configuration and starting over. Still I have indented headers whenever Friendica sends an email, and no other site using php on this server is indenting headers. At this point, I'm stumped completely.

Friendica Support reshared this.