note 28548 deleted from function.mail by aidan
| From: | aidan@php.net | Date: | Mon, 14 Feb 2005 02:06:03 +0000 |
| Subject: | note 28548 deleted from function.mail by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-84975@lists.php.net to get a copy of this message | ||
Note Submitter: jeremyp at easynet dot co dot uk
----
There seems to be lots of confusion about general e-mail and sendmail issues. Here's my
attempt to clear some of them up.
1. Line terminators.
The RFC states that the line terminator for SMTP is \r\n. If PHP just passes the message string to
the MTA unparsed, you must use \r\n to indicate line breaks in headers and the body. Some MTAs e.g.
sendmail can understand \n on its own and can even be configured to fix the problem - but don't
rely on it.
2. -f <sender address>
This is a sendmail option to set the envelope sender. It is a so called privileged option because
if any Unix user could issue it, they could easily impersonate any login account on the server.
This is why setting the user under which apache is running to be a trusted user allows you to use
this option (because sendmail is being invoked by the apache user). You can, of course set any
headers you like using the mail() function. These can include the From, Reply-to and Return-path
headers. If these are already in the mail when sendmail sees them, they will not be added or
altered. Most mail user agents will display these in preference to the envelope sender.
3. "From" in the text of the mail.
One poster has suggested you don't begin lines with the word "From" because it gets
munged with a ">". In fact this is nothing whatsoever to do with SMTP which is
perfectly capable of handling such lines. The "problem" is legitimate functionality of
the standard Unix local delivery agent. With normal Unix mail boxes - which are flat text files,
each message starts with a line consisting of the word "From" and then the envelope sender
and the date received. The ">" is inserted by the delivery agent to prevent normal
text lines from being interpreted as the start of a new message. The mail user agent should take
the ">" out again.
jeremyp (ex-sendmail consultant)