Connecting Tech Pros Worldwide Forums | Help | Site Map

70 characters limit when sending mails

woof
Guest
 
Posts: n/a
#1: Mar 3 '06
Hello,

I have built a "contact us" form on my Web site and am using the PHP
mail() function to send an e-mail to the Webmaster (that's me :-))
Everything works fine. What I would like to know however is whether it
is always necessary to limit each line of the message to 70 characters,
as is written in the documentation of the function (writing for
instance $this->message = wordwrap($message, 70)).
It seems to work fine without doing it in my case and the text is
easier to read.
I guess there must be a reason for the limit, but how to find out when
it is needed?


Jerry Stuckle
Guest
 
Posts: n/a
#2: Mar 4 '06

re: 70 characters limit when sending mails


woof wrote:[color=blue]
> Hello,
>
> I have built a "contact us" form on my Web site and am using the PHP
> mail() function to send an e-mail to the Webmaster (that's me :-))
> Everything works fine. What I would like to know however is whether it
> is always necessary to limit each line of the message to 70 characters,
> as is written in the documentation of the function (writing for
> instance $this->message = wordwrap($message, 70)).
> It seems to work fine without doing it in my case and the text is
> easier to read.
> I guess there must be a reason for the limit, but how to find out when
> it is needed?
>[/color]

It's probably because your email program (Outlook, Thunderbird, etc.) is
set up to wrap text at 70 characters. Mine is, but I can disable it.

No RFC about it, AFAIK - just the email program's attempt to keep long
lines from wrapping off the end of the screen.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Toby Inkster
Guest
 
Posts: n/a
#3: Mar 4 '06

re: 70 characters limit when sending mails


woof wrote:
[color=blue]
> Everything works fine. What I would like to know however is whether it
> is always necessary to limit each line of the message to 70 characters,
> as is written in the documentation of the function (writing for
> instance $this->message = wordwrap($message, 70)).[/color]

RFC 822 (Standard for the Format of ARPA Internet Text Messages) and its
successor RFC 2822 (Internet Message Format) say:

| There are two limits that this standard places on the number of
| characters in a line. Each line of characters MUST be no more than
| 998 characters, and SHOULD be no more than 78 characters, excluding
| the CRLF.

In practice, it is *sometimes* safe to ignore this.

However, tf you want to allow long lines, there are smarter ways of doing
this rather than just ignoring the RFCs. For example, you could try using
one of the MIME encoding options provided by PHP.

e.g.

$msgenc = base64encode($message);
$hdrs = "Content-Type: text/plain\r\n"
. "Content-Transfer-Encoding: base64\r\n";
mail($to, $subject, $msgenc, $hdrs);

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

woof
Guest
 
Posts: n/a
#4: Mar 4 '06

re: 70 characters limit when sending mails


Thank you Toby.
I understand that encoding the message would enable me to send the
message without having to worry about the recommended 70-characters per
line limit, right?
However, if I write
$msgenc = base64encode($message);
the email received is encoded (in other terms not decoded by Outlook
Express on my PC).
Is adding
Content-Transfer-Encoding: base64
sufficient?

Toby Inkster
Guest
 
Posts: n/a
#5: Mar 6 '06

re: 70 characters limit when sending mails


woof wrote:
[color=blue]
> I understand that encoding the message would enable me to send the
> message without having to worry about the recommended 70-characters per
> line limit, right?[/color]

Yep.
[color=blue]
> However, if I write
> $msgenc = base64encode($message);
> the email received is encoded (in other terms not decoded by Outlook
> Express on my PC).
> Is adding
> Content-Transfer-Encoding: base64
> sufficient?[/color]

You'll also want "Content-Type:text/plain" and "MIME-Version:1.0" headers.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

woof
Guest
 
Posts: n/a
#6: Mar 7 '06

re: 70 characters limit when sending mails


That's pretty clear. Thanks again.

Closed Thread