Bug 15724 - sendmail creating non-RFC-compliant headers with PHP8
Summary: sendmail creating non-RFC-compliant headers with PHP8
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.35.x
Hardware: All Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-15 04:01 UTC by Ralph
Modified: 2023-08-15 04:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralph 2023-08-15 04:01:54 UTC
As of PHP8.0, email headers are separated with a <CRLF> (`\r\n`) rather than <LF> (`\n`) as seen in older versions of PHP. This is causing all sorts of issues when used in conjunction with busybox's sendmail implementation in conjunction with an RFC-complaint SMTP server. 

I am no C expert, but from what I can see, busybox splits lines using xmalloc_fgetline() which trims the trailing `\n` (https://git.busybox.net/busybox/tree/libbb/get_line_from_file.c#n172), and then rebuilds the headers using send_r_n() (https://git.busybox.net/busybox/tree/mailutils/mail.c#n85) which appends a `\r\n` to each line. This results in header lines with a non-RFC-compliant `\r\r\n`.

This issue was first raised with with a project of mine (https://github.com/axllent/mailpit/issues/87), which led me to a a PHP bug reported (https://github.com/php/php-src/issues/8086) relating to the same thing. I would have assumed this issue would have been reported to busybox by now, but I can't see any reference to it.

Whilst there are some work-arounds, this isn't always an option, so fixing this at the sendmail level is the best approach as that appears to be where the issue is stemming from here.