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' => 'name@domain.com');

I've also tried this:

$email->cc = array('email' => 'name@domain.com', 'name' => 'My Name');

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

1 Answer 1


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' => 'name@example.com')

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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