codlib
codlib

Reputation: 638

Zend 1.12 Mail CC multiple recipients with same name

In one of our project, we are sending mails to users using Zend SMTP. The Zend version is 1.12.

We use the addCC function for sending copy of mails to a set of users. Two of the users are having same name but different email address. When we pass the recipient array to addCC function, the mail is going to only one of the user.

zend excepts the cc user list in the form of

$ccListArray = array('name1'=>'email1','name2'=>'email2','name3'=>'email3')
$mail->addCc($ccListArray);

When we have 2 users with same name, the first entry gets overwritten.

I can add each users individually, but we are sending hundreds of mails every day and looping the CC list is always not feasible.

Is there any other way i can add all mails to CC list at a time?

Upvotes: 1

Views: 258

Answers (1)

doydoy44
doydoy44

Reputation: 5772

The keys of an array must be unique.
May be you can try something like this:

$ccListArray = array(['name' => 'name1', 'email' => 'email1'],
                     ['name' => 'name2', 'email' => 'email2'],
                     ['name' => 'name3', 'email' => 'email3']);
foreach($ccListArray as $cc){
    $mail->addCc($cc['email'], $cc['name']);
}

Upvotes: 2

Related Questions