Skip to main content


Friendica 2022.10 seems to be sending malformed email notifications


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.

Friendica Support reshared this.

Ah wait, if you aren't using the phpmailer addon this isn't entirely accurate. We also are using the base mail() PHP function which relies on the current MTA of the server, either sendmail or postfix, etc...

What is your configuration in this regard?

Friendica Support reshared this.

I should be using the default mail setup, as I haven't changed anything. But I just found the PHP Mailer SMTP add-on. I can try enabling and configuring that for my local smtp server to see what that does.
Thanks very much for the help so far. If I don't use the addon, which is disabled by default, I have the Exim4 mail transfer agent on Ubuntu 22.04. It has a sendmail binary that identifies itself as Exin. It shows version 4.95 #2. Is it Exim that is putting leading spaces on some header lines?
#2
I’ve thoroughly checked the core code and I can confirm we don’t add the leading space. However, all the headers that show with a space were supplied as part of the PHP mail() call in Friendica, so I feel like it has to do with Exim. Would you be able to temporarily switch to Postfix to perform a test?

Friendica Support reshared this.

Just checked the headers of my notification mails. They look ok.

I'm using the phpmailer add-on and my own mail server with postfix.
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.
Looking further, these indented headers are put into the same array as the first one, see the file src/Util/EMailer/MailBuilder.php, so it's very unlikelly friendica it-self is the problem.
Are you using other addons that might affect generating or sending emails?
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.
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.
@Kyle πŸŽ™ 🎢 I have something you can try. Can you please manually replace the instances of \n by \r\n in src/Object/Email.php on lines 140 and 143 and try again, see if it changes anything?

Friendica Support reshared this.

@Hypolite Petovan Done. I'm still getting garbled emails, but there has definitely been an improvement. Now most of the Friendica headers are where they should be, but Reply-To, MIME-Version and Content-Type are still indented by one space.
@Kyle πŸŽ™ 🎢 EXCELLENT! I'll have a full patch in the next hour.

Friendica Support reshared this.

@Kyle πŸŽ™ 🎢 See https://github.com/friendica/friendica/pull/12173/files, there's an additional file to edit at src/Util/Emailer.php lines 166 through 168 with the same edit.

And then you should be ok. The big question is whether everyone else will still be ok. πŸ™ˆ

Friendica Support reshared this.

@Hypolite Petovan Worked like a charm! I do hope everyone else will be OK, because my emails are coming out perfect now. Thanks very much for the fix.
@Kyle πŸŽ™ 🎢 In the PHP documentation, they tell developers to use LF-only as a last resort, so I'm hoping that clients that can support LF will also support CRLF by now.

Friendica Support reshared this.

⇧