[tpop3d-discuss]Tpop3d breaking headers?

Mike Pinkerton pse at mindspring.com
Mon, 23 Aug 2004 05:52:10 -0400


Nigel:

PHP's mail function expects lines to be terminated with "\r\n" -- see 
notes at <http://us2.php.net/function.mail>.  That behavior is in 
line with RFC 2822 <ftp://ftp.rfc-editor.org/in-notes/rfc2822.txt>:

 From Section 2.1:
    Messages are divided into lines of characters.  A line is a series of
    characters that is delimited with the two characters carriage-return
    and line-feed; that is, the carriage return (CR) character (ASCII
    value 13) followed immediately by the line feed (LF) character (ASCII
    value 10).  (The carriage-return/line-feed pair is usually written in
    this document as "CRLF".)

    A message consists of header fields (collectively called "the header
    of the message") followed, optionally, by a body.  The header is a
    sequence of lines of characters with special syntax as defined in
    this standard. The body is simply a sequence of characters that
    follows the header and is separated from the header by an empty line
    (i.e., a line with nothing preceding the CRLF).

 From Section 2.2:
    Header fields are lines composed of a field name, followed by a colon
    (":"), followed by a field body, and terminated by CRLF.  A field
    name MUST be composed of printable US-ASCII characters (i.e.,
    characters that have values between 33 and 126, inclusive), except
    colon.  A field body may be composed of any US-ASCII characters,
    except for CR and LF.  However, a field body may contain CRLF when
    used in header "folding" and  "unfolding" as described in section
    2.2.3.  All field bodies MUST conform to the syntax described in
    sections 3 and 4 of this standard.

Your extra line breaks only seem to be occurring in some of the 
"additional headers" that are the fourth argument in PHP's mail 
function.  My bet is that there is something funky happening where 
those additional headers are defined in the PHP script, maybe an 
extra carriage return is being inserted inadvertantly.  Just a guess 
-- if your maildir folder is on a Linux or BSD box, reading the file 
there might not show a problem since "\n" is the Unix line ending, 
but in a desktop e-mail client the extra "\r" might show up as an 
extra line.

Anyway, I would start by taking another look at the maildir file to 
see if there are any extra "\r" characters there:

# cat file | sed l

If so, I would take a close look at the "additional headers" section 
of the PHP script.

--
Mike


At 16:54 +0930 2004/08/23, Nigel wrote:
>Hi,
>
>I have an issue with tpop3d 1.5.3 where some messages are receiving broken
>messages via extra line breaks.
>
>I am using maildir + auth-mysql and postfix as the MTA. Also tpop3d has been
>patched with the one liner to allow maildir mailbox creation if it doesn't
>exist.
>
>For your reference, I have included the source maildir file and received
>source email below.
>
>I know that it is because of "\r\n" in the php scripting. Is this RFC or is
>it an issue that needs to be looked at in tpop3d?
>
>P.s. Sorry if this has been brought up previously, but without a search
>function in mailing lists, its hard to go through every previous month.