Skip to content

Commit

Permalink
Fix mangling of auto-generated mails.
Browse files Browse the repository at this point in the history
s9y will encode the body of its auto-generated
mails as quoted-printable when imap_8bit() is
available. imap_8bit() will use "\r\n" as
linebreaks as mandated for SMTP transfer.
The result will be transmitted via PHP's
mail() function, using direct SMTP on
Windows and piping it to a MTA on Unix.

Most MTAs will cope just fine with those
linebreaks, while qmail will not; it will
replace all "\n" linebreaks with "\r\n",
so we get "\r\r\n" in our case. We can't
"fix" qmail (as its maintainer, if there
even is one, does not consider this
behaviour wrong), but we can replace the
line endings we get from imap_8bit().

The fix does work with qmail and Exim and
should work with sendmail and Postfix and
other MTAs, too. It may break sending
mail on Windows (i.e. lose all linebreaks),
but I think that's acceptable, as we'll
have more qmail installation than Windows
servers out there.

A workaround could be to set
serendipity['forceBase64']=true in
serendipity_config_local.inc.php, but I'd
prefer this fix.

Fixes s9y#644.

Backported from master branch.

Signed-off-by: Thomas Hochstein <thh@inter.net>
  • Loading branch information
th-h committed Oct 13, 2019
1 parent d36895b commit a2ad0bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Version 2.3.2-beta1 ()
------------------------------------------------------------------------

* Fix: Auto-generated mails submitted to qmail as MTA will get
mangled if encoded to quoted-printable due to qmail
changing "\r\n" linebreaks to "\r\r\n". Submit just "\n"
as linebreaks; other MTAs should cope with that.

* fix: Rotating an image did not rotate all responsive thumbnails

* fix: The wysiwyg editor stripped the figcaption element used
Expand Down
2 changes: 1 addition & 1 deletion include/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ function serendipity_sendMail($to, $subject, $message, $fromMail, $headers = NUL
if (LANG_CHARSET == 'UTF-8') {
if (function_exists('imap_8bit') && !$serendipity['forceBase64']) {
$maildata['headers'][] = 'Content-Transfer-Encoding: quoted-printable';
$maildata['message'] = imap_8bit($maildata['message']);
$maildata['message'] = str_replace("\r\n","\n",imap_8bit($maildata['message']));
} else {
$maildata['headers'][] = 'Content-Transfer-Encoding: base64';
$maildata['message'] = chunk_split(base64_encode($maildata['message']));
Expand Down

0 comments on commit a2ad0bd

Please sign in to comment.