I would like to see if there is a way to BCC me from the CCK Email Field Contact Form. I tried the Rules Module but I don't know which or how to add the necessary tokens to copy the contents of the Email Form in my Rules Email. Please let me know if there is an easy way around this. Thanks!

Chalo

Comments

web506’s picture

Hi, well after a while, I figured it out.

you have to add this piece of code to the module cck email

1- open the file email.module
2- look for this: function email_mail($key, &$message, $params)
3- find this piece of code

// Prepare the body:
$message['body'] = implode("\n\n", $msg);

and add the code below just underneath it.

add the following code below the
$message['headers'] += array(
'Bcc' => 'you@yoursite.com'
);

4- upload the module

I hope this helps!!!

eliosh’s picture

instead of altering email module file, create a new module and implement hook_mail_alter to add a BCC Header

web506’s picture

Thank you I will try that instead.

web506’s picture

Hi Eliosh,

I am trying this, it works fine from the regular contact form in my test drupal site, but I am also trying to learn how to get a copy from a mail sent from user to user ( user contact form ) this is what I am using:

function bccmails_mail_alter(&$message) {
$message['headers'] += array(
'Bcc' => 'me@domain.com'
);
}

in the module I created. Any ideas? I will really appreciate your help.

Thanks!

KAP10’s picture

I am trying to accomplish the exact same thing. I look forward to seeing the exact code we need to use.

eliosh’s picture

@web506
What kind of errors you have?

web506’s picture

Thanks I am not having any more issues with this, this is a great module!

pandreas’s picture

@web506

Can you drive me how I will add the function bccmails_mail_alter(&$message)?

And where?

I would like to bcc all emails sent when a new user is created by the administrator.

How I can do this?

Regards,

Andreas

adrnand’s picture

Version: 6.x-1.2 » 7.x-1.0

Has someone created this function for 7? I would like to CC a fixed email address on all emails submitted via the contact form.

Fly85’s picture

In your template.php

<?php
  function THEME_mail_alter(&$message) {
    $message['headers']['CC'] = 'email@domain.com';
    $message['headers']['BCC'] = 'email@domain.com';
  }
?>
adrnand’s picture

Thanks Fly85! Works perfectly.

sahuni’s picture

Thanks for #10.
How would I test for a specific field?
I'd like the cc just for an email field of a specific content type (exemple field_aaa_email) and do not want that cc for contact form or other email fields.