note 109872 deleted from function.mail by cmb

From: Date: Sun, 21 Jul 2019 08:49:39 +0000
Subject: note 109872 deleted from function.mail by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211644@lists.php.net to get a copy of this message
Note Submitter: Joost Brugman ---- When using mail() under a windows installation (tested under Xampp 1.7.7) any line in $headers that is (between the first and last properly formatted mail header and not a properly formatted mail headers itself) or (that is empty) is removed. As a result MIME formatted messages get scrambled. I am not sure if this behaviour is by design, but this is what it seems to do. Example $headers: 01 From: "me" <me@domain.com> 02 MIME-Version: 1.0 03 Content-Type: multipart/mixed; 04 boundary=streamline503e8a5d00efdMessage 05 06 --streamline503e8a5d00efdMessage 07 Content-Type: multipart/alternative; 08 boundary=streamline503e8a5d00efdBody 09 10 --streamline503e8a5d00efdBody 11 Content-Type: text/plain; 12 charset=UTF-8 13 Content-Transfer-Encoding: quoted-printable 14 15 This message is written in HTML only. 16 17 --streamline503e8a5d00efdBody 18 Content-Type: text/html; 19 charset=UTF-8 20 Content-Transfer-Encoding: quoted-printable 21 22 This is an email with <b>html</b>content 23 --streamline503e8a5d00efdBody-- 24 25 --streamline503e8a5d00efdMessage-- 26 27 . Here, lines 05, 09, 10, 14, 15, 16, 17 are removed. The first properly formatted mail header is on line 01. The last properly formatted mail header is on line 20. The before mentioned entries are between 01 and 20, not properly formatted mail headers themselves and are therefore removed. Also, lines 21, 24, 26 are removed because they are empty. As a result this message will be delivered, but the mime structure is broken, since relevant lines are left out. The solution is to pass lines 01 through 04 in $headers and to pass 06 through 26 to $message. $message will passed unchanged and the mime structure will remain intact.

« previous php.notes (#211644) next »