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



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to