note 41651 deleted from function.mail by aidan
| From: | aidan@php.net | Date: | Sun, 08 Aug 2004 15:36:38 +0000 |
| Subject: | note 41651 deleted from function.mail by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74238@lists.php.net to get a copy of this message | ||
Note Submitter: phpcomment@labres.at
----
"Note: You must use \r\n to separate headers, although some Unix mail transfer agents may work
with just a single newline (\n)."
This is WRONG. On Unix systems, any line ending (also between header fields) has to be \n. On
Windows Systems, it has to be \r\n.
Here is part of the sounce code in mail.c (in case of a Unix system):
sendmail = popen(sendmail_cmd, "w");
fprintf(sendmail, "To: %s\n", to);
fprintf(sendmail, "Subject: %s\n", subject);
if (headers != NULL) {
fprintf(sendmail, "%s\n", headers);
}
fprintf(sendmail, "\n%s\n", message);
ret = pclose(sendmail);
On Windows Systems, the SMTP session is handled within SendText() in sendmail.c, which sends headers
and message as is, so the line endings have to be \r\n.
And there is a further bug in example 4:
| $headers .= "Bcc: birthdaycheck@example.com\r\n";
remove the ending line break
The header must not end with a line break. As you can see in above code snipet, the mail
implementation adds a \n at the end of the header.