PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail_Mime » Bug #3490

mime->headers; change merge order

Details

Request #3490mime->headers; change merge order
Submitted2005-02-16 12:12 UTC
Fromwouter dot monkhorst at gmail dot com
StatusBogus
PackageMail_Mime
PHP Version5.0.2
Roadmaps(Not assigned)

Comments

[2005-02-16 12:12 UTC] wouter dot monkhorst at gmail dot com

Description:
------------
When reusing the mime object in a loop, the header cannot be updated with a new 'To' field, see 'reproduce code'.

A change of order in the array_merge would solve this problem:

file: mime.php, line: 536 - 556

function &headers($xtra_headers = null)
{
// Content-Type header should already be present,
// So just add mime version header
$headers['MIME-Version'] = '1.0';
if (isset($xtra_headers)) {
$headers = array_merge($headers, $xtra_headers);
}
$this->_headers = array_merge($this->_headers, $headers);

return $this->_encodeHeaders($this->_headers);
}

Reproduce code:
---------------
$mime->setHTMLBody($html);
$body = $mime->get();

foreach ($recipients as $user_id=>$recipient) {

$hdrs_arr = array('Subject' => $subject,
'From' => $from,
'To' => $recipient);

$hdrs = $mime->headers($hdrs_arr);
print_r($hdrs);

$this->send($recipient, $hdrs, $body);
}

Expected result:
----------------

[2005-02-18 10:00 UTC] wouter dot monkhorst at gmail dot com

this feature request equals request#2952 (http://pear.php.net/bugs/2952)