473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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.
Nov 22 '07 #1
9 5845
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
Nov 22 '07 #2
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?
Nov 22 '07 #3
On Thu, 22 Nov 2007 18:13:52 +0100, Matthew <ma*****@spamkiller.comwrote:
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
Nov 22 '07 #4
Rik Wasmus emailed this:
On Thu, 22 Nov 2007 18:13:52 +0100, Matthew <ma*****@spamkiller.comwrote:
>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.
Nov 22 '07 #5
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/
Nov 23 '07 #6
On 22 Nov, 16:47, John Dunlop <j...@dunlop.namewrote:
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.
Nov 23 '07 #7
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
Nov 24 '07 #8
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.
Nov 24 '07 #9
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
Nov 24 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Dvali | last post by:
Hello. I have a problem with sending Unicode text in mail message. So what I do: First of all I have some template file like this: ================================= <html> <head><title>Test...
9
by: Peter Afonin | last post by:
Hello, I created an e-mail form pretty much as described in this article: http://www.4guysfromrolla.com/webtech/080801-1.shtml. It works great, but I cannot figure out one thing: I need to...
2
by: Robbie De Sutter | last post by:
Hello, How do I open a new, empty e-mail message from the default e-mail client whereby the sender is given and a file is attached? Currently I use the command (vb.net): ---...
2
by: UJ | last post by:
How do you send mail to multiple users? I've got a string with e-mail addresses separated by semi colon and when I create the MailMessage doing: System.Net.Mail.MailMessage lobjMail = new...
5
by: Robert Dufour | last post by:
I am trying to use framework 1.1 - stuck with it. to send emails from a windows form application. The email messages can have attachments, usually two and they can be either text or sounds (wav...
6
by: Karl Groves | last post by:
I'm trying to work out a mail system which can send an attachment as well as an HTML formatted message (and a default plain text version). I found some pretty good code on PHP.net and modified it...
0
by: robert | last post by:
can anyone contribute to this question about correct auto line break in mail header lines: https://sourceforge.net/tracker/?func=detail&aid=1645148&group_id=5470&atid=105470
1
by: webandwe | last post by:
Hi, I tried to get a script or something to send my e-mial in HTML format becasuse I want to add tables to line up certain text. How do I get the e-mail to go from plain text to HTML? Thanks ...
1
by: vps | last post by:
Do I need to break a mail message into lines of 70 characters each? Apache 2.2 with PHP 5.2.5 sends messages with lines of any length at my localhost with all characters intact. Thank you very...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.