Fwd: PEAR Mail
| From: | Chuck Hagenbuch | Date: | Wed, 11 Jun 2003 13:26:10 +0000 |
| Subject: | Fwd: PEAR Mail | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-17303@lists.php.net to get a copy of this message | ||
----- Forwarded message from saramaca@libertysurf.fr -----
Date: Wed, 11 Jun 2003 15:28:52 +0200
From: Michael Guitton <saramaca@libertysurf.fr>
Reply-To: Michael Guitton <saramaca@libertysurf.fr>
Subject: PEAR Mail
To: Chuck Hagenbuch <chuck@horde.org>
Hi Chuck,
When using your PEAR Mail module as an interface for mail() PHP
function, I noticed that I would got an extraneous line feed before
the actual message body. Looking at the source code, I found out that
mail headers were "incorrecly" tied together: you use a single "\n"
character where as you should insert "\r\n" between header fields
(please see specific note at <http://www.php.net
/manual/en/function.mail.php>)
I took the liberty of tweaking Mail.php source. Please let me know if
my changes have an impact with qmail or sendmail. Here is the class
function I modified:
Also why don't you use a switch statement ?
--BEGIN
function prepareHeaders($headers)
{
// Look out for the From: value to use along the way.
$text_headers = array(); // text representation of headers
$from = null;
foreach ($headers as $key => $val) {
if ($key == 'From') {
include_once 'Mail/RFC822.php';
$from_arr = Mail_RFC822::parseAddressList($val,
'localhost', false);
$from = $from_arr[0]->mailbox . '@' . $from_arr[0]->host;
if (strstr($from, ' ')) {
// Reject outright envelope From addresses with spaces.
return false;
}
$text_headers[] = $key . ': ' . $val;
} else if ($key == 'Received') {
// put Received: headers at the top, since Received:
// after Subject: in the header order is sometimes used
// as a spam trap.
array_unshift($text_headers, $key . ': ' . $val);
} else {
$text_headers[] = $key . ': ' . $val;
}
}
// You must use "\r\n" to separate headers - mg
$text_headers= join("\r\n", $text_headers);
return array($from, $text_headers);
}
--END
--
Michael Guitton
mailto:saramaca@libertysurf.fr
----- End forwarded message -----
-chuck
--
Charles Hagenbuch, <chuck@horde.org>
The alligators were there, too, in a bathtub inside the house.