Home » Mail » Mail » Bug #1460
patch to handle multiple cc/bcc/etc. fields
Details
| Submitted | 2004-05-21 01:45 UTC |
|---|---|
| From | colin at easydns dot com |
| Assigned | jon |
| Status | Closed |
| Package | |
| PHP Version | 4.3.6 |
| OS | Debian Linux |
| Roadmaps | (Not assigned) |
Comments
[2004-05-21 01:45 UTC] colin at easydns dot com
Description:
------------
I sent this email directly to Chuck and Jon, but I'm not
sure if they ever got it.
The issue is that I will need to send emails that are
CC-ed or BCC-ed to several addresses. Right now, Mail-
>send() can accept an array of receipients for the To:
field, but the Cc: and Bcc: fields are part of the extra
headers and are assumed to be strings.
I propose the following patch, which will allow extra
field parameters to be strings or arrays and, if they
are arrays, to concatenate them first. I've also added
a minor change to compare the header keys case-
insensitively, since they could be provided as "From" or
"FROM" or even "FroM", and still be valid (as per RFC
822).
Let me know what you think ...
?--
Colin Viebrock
Co-Founder, easyDNS Technologies Inc.
http://www.easydns.com/
Reproduce code:
---------------
cmv@alpha:~$ diff -u /pear/Mail.php ./Mail.php
--- /pear/Mail.php 2004-04-16 15:42:13.000000000 -0400
+++ ./Mail.php 2004-05-19 11:18:48.000000000 -0400
@@ -128,7 +128,7 @@
$from = null;
foreach ($headers as $key => $value) {
- if ($key === 'From') {
+ if (strtolower($key) === 'from') {
include_once 'Mail/RFC822.php';
$addresses = Mail_RFC822::parseAddressList($value, 'localhost',
@@ -141,12 +141,15 @@
}
$lines[] = $key . ': ' . $value;
- } elseif ($key === 'Received') {
+ } elseif (strtolower($key) === 'received') {
// Put Received: headers at the top. Spam detectors often
// flag messages with Received: headers after the Subject:
// as spam.
array_unshift($lines, $key . ': ' . $value);
} else {
+ if (is_array($value)) {
+ $value = implode(', ', $recipients);
+ }
$lines[] = $key . ': ' . $value;
}
}
Expected result:
----------------
n/a
Actual result:
--------------
n/a