Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to edit the Contact Form plugin to copy the email to another address.

Looking in apps/models/EmailModel.php I see this for CC:

'cc' => array(AttributeType::Mixed);

Looking in apps/services/EmailService.php I see this:

// Add any CC's
if (!empty($emailModel->cc))
    foreach ($emailModel->cc as $cc)
        if (!empty($cc['email']))
            $ccEmail = $cc['email'];

            $ccName = !empty($cc['name']) ? $cc['name'] : '';
            $email->addCC($ccEmail, $ccName);

So, it looks like 'cc' needs to be array? I tried it without it being an array and I get an invalid foreach error. At the moment, I've added this line to ContactFormService.php (after line 45):

$email->cc = array('email' => '');

I've also tried this:

$email->cc = array('email' => '', 'name' => 'My Name');

The problem: The email is not being CC'd and I'm not getting any errors. Anyone?

share|improve this question
up vote 5 down vote accepted

From that code snippet, it looks like you're needing nested arrays. Try setting your $email->cc property like this.

$email->cc = array(
    array('name' => 'Your Name', 'email' => '')

The code snippet is iterating over $email->cc as $cc as the first array, then going into cc['name'] and cc['email'] as a nested array.

share|improve this answer
Perfect. Thanks. – Clive Portman Jun 21 '14 at 13:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.