mail() - message lines <= 70 chars - PHP

This is a discussion on mail() - message lines <= 70 chars - PHP ; I'm using PHP version 4.4.3. The manual page for PHP's mail() function (URL below) says that for the message (IE. email body) &quot;Each line should be separated with a LF (\n). Lines should not be larger than 70 characters.&quot; http://uk2.php.net/manual/en/function.mail.php ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

mail() - message lines <= 70 chars

  1. Default mail() - message lines <= 70 chars

    I'm using PHP version 4.4.3.

    The manual page for PHP's mail() function (URL below) says that for the
    message (IE. email body) "Each line should be separated with a LF (\n).
    Lines should not be larger than 70 characters."

    http://uk2.php.net/manual/en/function.mail.php

    To see what happened I just sent an email using mail() with one of its
    lines exactly 100 chars. It was sent perfectly by sendmail as a line of
    100 chars and no newline. PHP did not seem to mind at all.

    Why the limitation of <= 70 chars per line, and why does my version of PHP
    not seem to care?

    Thanks all.

  2. Default Re: mail() - message lines <= 70 chars

    Matthew:

    > The manual page for PHP's mail() function (URL below) says that for the
    > message (IE. email body) "Each line should be separated with a LF (\n).


    Should be CRLF.

    http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1

    > Lines should not be larger than 70 characters."


    Should be 78.

    http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1.1

    --
    Jock

  3. Default Re: mail() - message lines <= 70 chars

    John Dunlop emailed this:
    > Matthew:
    >
    >> The manual page for PHP's mail() function (URL below) says that for the
    >> message (IE. email body) "Each line should be separated with a LF (\n).

    >
    > Should be CRLF.
    >
    > http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1
    >
    >> Lines should not be larger than 70 characters."

    >
    > Should be 78.
    >
    > http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1.1
    >
    > --
    > Jock


    Thanks.

    Why do the long lines of 100 chars work for me anyway?

  4. Default Re: mail() - message lines <= 70 chars

    On Thu, 22 Nov 2007 18:13:52 +0100, Matthew <matthew@spamkiller.com> wrote:
    > John Dunlop emailed this:
    >> Matthew:
    >>> The manual page for PHP's mail() function (URL below) says that for the
    >>> message (IE. email body) "Each line should be separated with a LF (\n).

    >> Should be CRLF.
    >> http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1
    >>
    >>> Lines should not be larger than 70 characters."

    >> Should be 78.
    >> http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1.1

    >
    > Why do the long lines of 100 chars work for me anyway?


    1. PHP doesn't check it: you, as the programmer, should take care of it.
    2. Most email clients/servers ar robust enough to handle more characters.
    The fact that almost all can is still not a reason to let the number of
    characters slide though.
    --
    Rik Wasmus

  5. Default Re: mail() - message lines <= 70 chars

    Rik Wasmus emailed this:
    > On Thu, 22 Nov 2007 18:13:52 +0100, Matthew <matthew@spamkiller.com> wrote:
    >> John Dunlop emailed this:
    >>> Matthew:
    >>>> The manual page for PHP's mail() function (URL below) says that for the
    >>>> message (IE. email body) "Each line should be separated with a LF (\n).
    >>> Should be CRLF.
    >>> http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1
    >>>
    >>>> Lines should not be larger than 70 characters."
    >>> Should be 78.
    >>> http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1.1

    >>
    >> Why do the long lines of 100 chars work for me anyway?

    >
    > 1. PHP doesn't check it: you, as the programmer, should take care of it.
    > 2. Most email clients/servers ar robust enough to handle more
    > characters. The fact that almost all can is still not a reason to let
    > the number of characters slide though.


    Thanks Rik. I'll just add a newline every 70 chars then.

  6. Default Re: mail() - message lines <= 70 chars

    Matthew wrote:

    > Thanks Rik. I'll just add a newline every 70 chars then.


    PHP has a function called wordwrap() that may be useful for you.

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 17:53.]

    It'll be in the Last Place You Look
    http://tobyinkster.co.uk/blog/2007/11/21/no2id/

  7. Default Re: mail() - message lines <= 70 chars

    On 22 Nov, 16:47, John Dunlop <j...@dunlop.name> wrote:
    > Matthew:
    >
    > > The manual page for PHP's mail() function (URL below) says that for the
    > > message (IE. email body) "Each line should be separated with a LF (\n).

    >
    > Should be CRLF.
    >
    > http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1
    >
    > > Lines should not be larger than 70 characters."

    >
    > Should be 78.
    >
    > http://www.apps.ietf.org/rfc/rfc2822.html#sec-2.1.1
    >
    > --
    > Jock


    No - that's SMTP which is a specific transport mechanism for email
    (actually its a whole family of protocols but lets not go there) its
    up to the MUA ('mail' command on Unix or the SMTP implementation
    within PHP for |MSWin) to **convert** the message to a suitable format
    for the MTA, which may in turn encode the message in a different
    format depending on the carrier protocol.

    Perhaps historically the SMTP implementation in PHP couldn't
    accomodate this.

    If you sniff the SMTP connection you'll see that long lines do get
    wrapped - but the original message is restored when it comes out the
    MUA at the other end.

    C.

  8. Default Re: mail() - message lines <= 70 chars

    C. (http://symcbean.blogspot.com/):

    > No - that's SMTP which is a specific transport mechanism for email
    > (actually its a whole family of protocols but lets not go there) its
    > up to the MUA ('mail' command on Unix or the SMTP implementation
    > within PHP for |MSWin) to **convert** the message to a suitable format
    > for the MTA, which may in turn encode the message in a different
    > format depending on the carrier protocol.


    Right.

    > Perhaps historically the SMTP implementation in PHP couldn't
    > accomodate this.
    >
    > If you sniff the SMTP connection you'll see that long lines do get
    > wrapped - but the original message is restored when it comes out the
    > MUA at the other end.


    I wonder where PHP's figure 70 came from? If long lines do get
    wrapped but you still recommended a limit, would you not recommend
    78, in line with the transfer protocol?

    On the other note, line endings seem a bit messy: \n for the message
    body but \r\n for headers, whereas the transfer protocol demands \r\n
    across the board. Then, I suppose, the whole business of line ending
    conventions is messy.

    --
    Jock

  9. Default Re: mail() - message lines <= 70 chars

    Toby A Inkster emailed this:
    > Matthew wrote:
    >
    >> Thanks Rik. I'll just add a newline every 70 chars then.

    >
    > PHP has a function called wordwrap() that may be useful for you.


    Thanks Toby. I already found it looking through the string functions in
    the manual for an appropriate function to use.

    Cheers.

  10. Default Re: mail() - message lines <= 70 chars

    John Dunlop emailed this:
    > C. (http://symcbean.blogspot.com/):
    >
    >> No - that's SMTP which is a specific transport mechanism for email
    >> (actually its a whole family of protocols but lets not go there) its
    >> up to the MUA ('mail' command on Unix or the SMTP implementation
    >> within PHP for |MSWin) to **convert** the message to a suitable format
    >> for the MTA, which may in turn encode the message in a different
    >> format depending on the carrier protocol.

    >
    > Right.
    >
    >> Perhaps historically the SMTP implementation in PHP couldn't
    >> accomodate this.
    >>
    >> If you sniff the SMTP connection you'll see that long lines do get
    >> wrapped - but the original message is restored when it comes out the
    >> MUA at the other end.

    >
    > I wonder where PHP's figure 70 came from? If long lines do get
    > wrapped but you still recommended a limit, would you not recommend
    > 78, in line with the transfer protocol?
    >
    > On the other note, line endings seem a bit messy: \n for the message
    > body but \r\n for headers, whereas the transfer protocol demands \r\n
    > across the board. Then, I suppose, the whole business of line ending
    > conventions is messy.


    It seems a strange for PHP to place an extra limitation like this on line
    lengths. It's not really a problem as line wrapping at 70 chars looks
    perfectly neat in all email clients I've ever used. As it happens between
    70 and 75 chars are the settings I've always used when manually setting
    word wrap in my email client's options.

    My question was why PHP places this restriction at all. It's not even
    sending the mail itself anyway, just passing the email to 'sendmail',
    surely then it should simply be concerned with whatever line length
    restrictions 'sendmail' imposes.

    I've just looked in the sendmail manual which says it conforms to RFC 821,
    this is the SMTP standard, URL - http://www.ietf.org/rfc/rfc0821.txt

    The relevant bit of the RFC 821 SMTP standard says:

    "Text Line - The maximum total length of a text line including the <CRLF>
    is 1000 characters (but not counting the leading dot duplicated for
    transparency)."

    AFAICT SMTP does not place any further restrictions on message body line
    lengths (though other fields do have text length restrictions such as the
    reply line being a max. of 512 chars). I can't find any reference in the
    protocol to message body lines (or any other lines) being further limited
    to either 70 or 78 characters.

    With that said, why is PHP concerned with further limits? Why not just let
    the user enter their own newlines, the programmer add a CRLF at 998 chars
    if necessary, and let the recipient's email client handle line wrapping as
    per it's own settings/user options?

    Any comments?

    Regards, etc..

    Matthew

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Print lines longer than 80 chars
    By Application Development in forum C
    Replies: 17
    Last Post: 12-16-2007, 08:56 PM
  2. win32 and chars()/lines() - timed input
    By Application Development in forum REXX
    Replies: 0
    Last Post: 09-12-2007, 02:08 PM
  3. Replies: 4
    Last Post: 05-28-2007, 05:23 PM
  4. Repeated message lines
    By Application Development in forum Microsoft Exchange
    Replies: 1
    Last Post: 12-20-2004, 06:16 PM
  5. end off line chars in mail message body
    By Application Development in forum Mutt
    Replies: 8
    Last Post: 10-18-2004, 08:40 PM