ZF-928: Zend_Mail mixes To: and Bcc: headers on multiple Bcc

Description

Again, this is an issue that was previously reported to the fw-general list and is still not fixed in r3503. Sorry about not reporting it earlier as an issue. I think this is a major misbehavior of Zend_Mail and if possible should be fixed before the 0.8 release.

given the following code:


$mail = new Zend_Mail();
$mail->setSubject('my subject');
$mail->setBodyText('my body');
$mail->setFrom('info@onlime.ch');
$mail->addTo('to.address@email.com');
$mail->addBcc('first.bcc@email.com');
$mail->addBcc('second.bcc@email.com');
//print_r($mail);
$mail->send();

The print_r($mail) output before sending the mail looks fine:


    [_headers:protected] => Array
        (
            [Subject] => Array
                (
                    [0] => my subject
                )

            [From] => Array
                (
                    [0] => "" 
                    [append] => 1
                )

            [To] => Array
                (
                    [0] => 
                    [append] => 1
                )

            [Bcc] => Array
                (
                    [0] => 
                    [append] => 1
                    [1] => 
                )

        )

The resulting email got the following messed up header:


To: 

I neither received the mail on first.bcc@email.com nor on second.bcc@email.com

Comments

I've done a little research on this. When using a generic transport (one that simply extends the abstract), everything works perfectly -- to and bcc addresses are reported with the correct headers. However, when I use a sendmail-type transport, I get slightly different results than those reported, but equally bad: I have no To: header at all, only Bcc headers. I'll resolve this issue shortly.

Should be resolved in current SVN; please test. If you continue to experience issues, please provide detailed information as to the transport, MTA, and OS used so we can better replicate the issue.

Now it does no longer mix To and Bcc addresses but we get double To: lines in our mail header:

...
To: 
Subject: my subject
From: "" 
To: 
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
...

The Bcc recipients correctly receive the email but all emails contain a doubled To:

Tested on PHP 5.2.1standard-mail() transport, Postfix 2.3.6 on a Debian Linux Etch box.

Resolved in trunk r4010