note 41651 added to function.mail

From: Date: Sun, 18 Apr 2004 12:57:03 +0000
Subject: note 41651 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-68286@lists.php.net to get a copy of this message
"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. ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41651 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41651&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41651&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68286) next »