Bug 15724

Summary: sendmail creating non-RFC-compliant headers with PHP8
Product: Busybox Reporter: Ralph <axllent>
Component: Standard ComplianceAssignee: unassigned
Status: NEW ---    
Severity: major CC: busybox-cvs
Priority: P5    
Version: 1.35.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

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.