Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45326 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62413 invoked from network); 21 Aug 2009 17:00:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Aug 2009 17:00:32 -0000 Received: from [127.0.0.1] ([127.0.0.1:3360]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 9B/3D-26842-FA2DE8A4 for ; Fri, 21 Aug 2009 13:00:31 -0400 Authentication-Results: pb1.pair.com header.from=php.net@chris.cs278.org; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php.net@chris.cs278.org; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain chris.cs278.org designates 87.230.14.38 as permitted sender) X-PHP-List-Original-Sender: php.net@chris.cs278.org X-Host-Fingerprint: 87.230.14.38 lvps87-230-14-38.dedicated.hosteurope.de Linux 2.5 (sometimes 2.4) (4) Received: from [87.230.14.38] ([87.230.14.38:51129] helo=lvps87-230-14-38.dedicated.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B3/FB-26842-A83CE8A4 for ; Fri, 21 Aug 2009 11:55:59 -0400 Received: from sandman.cs278.org (unknown [89.240.163.27]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "sandman.cs278.org", Issuer "CA Cert Signing Authority" (verified OK)) by lvps87-230-14-38.dedicated.hosteurope.de (Postfix) with ESMTPS id 0C24A8740006 for ; Fri, 21 Aug 2009 17:55:51 +0200 (CEST) Received: from sandman.cs278.org (localhost [127.0.0.1]) by sandman.cs278.org (Postfix) with ESMTP id 1B72E2BDCD for ; Fri, 21 Aug 2009 16:55:50 +0100 (BST) Received: from [192.168.0.219] (kinslayer.home.cs278.org [192.168.0.219]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: chris@cs278.org) by sandman.cs278.org (Postfix) with ESMTPSA id EBD3F2BCB0 for ; Fri, 21 Aug 2009 16:55:49 +0100 (BST) Message-ID: <4A8EC373.8040002@chris.cs278.org> Date: Fri, 21 Aug 2009 16:55:31 +0100 User-Agent: Thunderbird 2.0.0.22 (X11/20090608) MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP [sandman.cs278.org] Subject: mail() and header folding/line endings From: php.net@chris.cs278.org (Chris Smith) Hi, I've encountered difficulties utilising the mail() function properly under a NIX environments while conforming to RFC 2822. There two specific issues, one is a code problem the other a documentation issue they are intertwined so I thought best run it by here and see that people understand the issue before I head to the bug tracker. As you are no doubt aware mail() operates using the system sendmail interface under NIX environments, and under Windows it either utilises a sendmail binary or more commonly the SMTP feature. The problem stems from confusion and inappropriate application of the SMTP standards to the sendmail interface. Under a NIX environment the sendmail interface operates taking an e-mail message constructed using the system line ending, LF. I've confirmed this applies to the Postfix sendmail interface [1], and could ask other vendors. Under Windows either the sendmail binary or SMTP is utilised. The correct line endings for SMTP are certainly CR-LF, sendmail I guess could be either. The documentation mentions to use CR-LF as the line endings for the $additional_headers parameters whilst the function implementation utilises LFs [2] which results in a mix of line endings, which is worse than incorrect line endings. There is a 7 year old bug open about this inconsistency [3] and as of yet nobody has fixed it, I hope this can be rectified. The second issue I have is quite a show stopper with regards to properly formatted emails under the NIX environment; email headers maybe no longer than 998 characters but the advised cut off is 78, a long header should be folded over two lines with some white space indentation. [4] As the To and Subject headers are populated from the function arguments of the same name they pass through additional checks over the other headers. The problem arises with the SKIP_LONG_HEADER_SEP macro [5] which only skips over the SMTP standard of CR-LF-WSP and not LF-WSP required for NIX sendmail as a consequence the LF is replace with a space effectively unfolding the folded line. It is therefore impossible to correctly create an email using mail() with a large number of recipients or a long subject, the effective limit of text shrinks when encoding is used for non ASCII characters as well. Can anyone provide me with any insight? Regards, Chris [1] http://thread.gmane.org/gmane.mail.postfix.user/200784 [2] http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/ext/standard/mail.c?view=markup#l312 [3] http://bugs.php.net/bug.php?id=15841 http://tools.ietf.org/html/rfc2822#section-2.2.3 [4] http://tools.ietf.org/html/rfc2822#section-2.2.3 [5] http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/ext/standard/mail.c?view=markup#l56 -- Chris Smith