[tpop3d-discuss]Tpop3d breaking headers?

Nigel nigel at bullmedia.com.au
24 Aug 2004 09:12:27 +0930


I thought about php headers for a while,  redid the code but couldn't find anything wrong since it wad all in shape.
The box is freebsd and I discovered editing in nano and resaving seems to fix the issue which from all I could tell, deleting the windows line  breaks (\r I think?). using this logic I deleted the \r from the php  script headers (the headers were giving to mail()) and the problem is... 'solved'. This is a hack but the result is there. One thing though, this script worked fine on win32(developers box) and it has been on linux and bsd before without a problem. The only difference is now we were using: 
postfix v2 not v1
bsd AND tpop (server the scripts reside on is the final mail destination)
Thanks for the help. 

-----Original Message-----
From:  Mike Pinkerton 
Date:  23/8/04 7:22 pm
To:  Nigel 
Cc:  tpop3d-discuss@lists.beasts.org
Subj:  Re: [tpop3d-discuss]Tpop3d breaking headers?

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.
>