<p>The way you do it now only adds email addresses as an array. You'll have to specify both email and name keys too, so it becomes like this:</p>

<pre><code>$email-&gt;cc = array(
    array('email' =&gt; 'email@email.com', 'name' =&gt; 'Name')
);
</code></pre>

CC BY-SA 3.0
2015-06-22T09:32:09.700Z
2015-06-22T17:31:11.653Z
2015-06-22T17:31:11.653Z
Bob Olde Hampsink
<p>Below is my code for sending mail and this is working fine but when i set cc or bcc mail is not sent them.</p>

<pre><code>    $email = new EmailModel();
    $emailSettings = craft()-&gt;email-&gt;getSettings();

    $email-&gt;fromEmail = $emailSettings['emailAddress'];
    $email-&gt;replyTo   = $message-&gt;fromEmail;
    $email-&gt;sender    = $emailSettings['emailAddress'];
    $email-&gt;fromName  = $settings-&gt;prependSender . ($settings-&gt;prependSender &amp;&amp; $message-&gt;fromName ? ' ' : '') . $message-&gt;fromName;
    $email-&gt;toEmail   = $toEmail;
    $email-&gt;cc   = explode(',', $message-&gt;fromEmail);
    $email-&gt;subject   = $settings-&gt;prependSubject . ($settings-&gt;prependSubject &amp;&amp; $message-&gt;subject ? ' - ' : '') . $message-&gt;subject;
    $email-&gt;body      = $message-&gt;message;

    if ($message-&gt;attachment)
    {
        $email-&gt;addAttachment($message-&gt;attachment-&gt;getTempName(), $message-&gt;attachment-&gt;getName(), 'base64', $message-&gt;attachment-&gt;getType());
    }

    craft()-&gt;email-&gt;sendEmail($email);
</code></pre>

<p>please correct me where i wrong.</p>

<p>Thanks</p>

<emails>
How to set CC or BCC emails to EmailModel?
# How to set CC or BCC emails to EmailModel?

(Asked by: username_0 on 2015-06-22)

Below is my code for sending mail and this is working fine but when i set cc or bcc mail is not sent them.
    $email = new EmailModel();
    $emailSettings = craft()->email->getSettings();

    $email->fromEmail = $emailSettings['emailAddress'];
    $email->replyTo   = $message->fromEmail;
    $email->sender    = $emailSettings['emailAddress'];
    $email->fromName  = $settings->prependSender . ($settings->prependSender && $message->fromName ? ' ' : '') . $message->fromName;
    $email->toEmail   = $toEmail;
    $email->cc   = explode(',', $message->fromEmail);
    $email->subject   = $settings->prependSubject . ($settings->prependSubject && $message->subject ? ' - ' : '') . $message->subject;
    $email->body      = $message->message;

    if ($message->attachment)
    {
        $email->addAttachment($message->attachment->getTempName(), $message->attachment->getName(), 'base64', $message->attachment->getType());
    }

    craft()->email->sendEmail($email);

please correct me where i wrong.
Thanks

**Tags:** emails

---

## 1 answers

### Answer by username_1 on 2015-06-22. Score: 9 | Accepted answer

The way you do it now only adds email addresses as an array. You'll have to specify both email and name keys too, so it becomes like this:
$email->cc = array(
    array('email' => 'email@email.com', 'name' => 'Name')
);


---

