I have a contact form that uses PHP's mail() function. It recently
came to my attention that (some?) MS-Windows mail servers may not
properly process data given to the mail() function that's only
newline-terminated.
The mail() function takes up to five parameters:
mail(recipient, subject, message, [headers [,parameters]])
The ones of interest here are the first four. The questions are
these:
1. Since recipient and subject are not multi-line, and, from the
web form, don't even contain newlines, is it safe to assume
they need neither newlines nor carriage-returns?
2. The message, from the web form, contains newlines. I assume
all newlines need carriage-returns inserted in front of them?
3. The headers are created, in the web form processing, by
appending newline-terminated strings to a variable (e.g.:
headers .= "blah: yadda\n";). I presume that this string
likewise needs carriage-returns inserted before the newlines?
4. I've seen mention of problems with "hanging carriage-returns."
I presume that simply means there should be no line, blank or
otherwise, that contains a carriage-return w/o an accompanying
newline?
Assuming all the above to be true, my four parameters would look like:
recipient: "somebody@examp le.com"
subject: "Some subject"
message: "Some message\r\ntext \r\ngoes here\r\n"
headers: "Header1: foo\r\nHeader2: bar\r\nHeader3: baz\r\n"
Is the above what (some?) MS-Windows mail servers want to see?
TIA,
Jim
--
Jim Seymour | PGP Public Key available at:
| http://www.uk.pgp.net/pgpnet/pks-commands.html
|
| http://jimsun.LinxNet.com
came to my attention that (some?) MS-Windows mail servers may not
properly process data given to the mail() function that's only
newline-terminated.
The mail() function takes up to five parameters:
mail(recipient, subject, message, [headers [,parameters]])
The ones of interest here are the first four. The questions are
these:
1. Since recipient and subject are not multi-line, and, from the
web form, don't even contain newlines, is it safe to assume
they need neither newlines nor carriage-returns?
2. The message, from the web form, contains newlines. I assume
all newlines need carriage-returns inserted in front of them?
3. The headers are created, in the web form processing, by
appending newline-terminated strings to a variable (e.g.:
headers .= "blah: yadda\n";). I presume that this string
likewise needs carriage-returns inserted before the newlines?
4. I've seen mention of problems with "hanging carriage-returns."
I presume that simply means there should be no line, blank or
otherwise, that contains a carriage-return w/o an accompanying
newline?
Assuming all the above to be true, my four parameters would look like:
recipient: "somebody@examp le.com"
subject: "Some subject"
message: "Some message\r\ntext \r\ngoes here\r\n"
headers: "Header1: foo\r\nHeader2: bar\r\nHeader3: baz\r\n"
Is the above what (some?) MS-Windows mail servers want to see?
TIA,
Jim
--
Jim Seymour | PGP Public Key available at:
| http://www.uk.pgp.net/pgpnet/pks-commands.html
|
| http://jimsun.LinxNet.com
Comment