Hi,
Is there a way to add a default cc or bcc to each email that is sent out from the site using this module?
Thanks

Comments

johnv’s picture

Hi, i added this code in a custom module (for D7-version). However, the mails are considered BCC, not CC.
It uses the user reference fields field_ in the nodes of type that are sent.

It would be nice if this (in some way) could be incorporated in the module.

function <my_module>_form_print_mail_form_alter(&$form, &$form_state) {
  // read node from first numeric path part
  $path_parts = explode('/',$form['path']['#value']);
  foreach ($path_parts as $part) {
    if (is_numeric($part)) {
      $node = node_load($part);
      break;
    }
  }

  if($node->type == <my_node_type>) {
    $emailadresses = array();
    if(!empty($node->field_<my_user_ref>)) {
      foreach($node->field_<my_user_ref> AS $lng => $records) {
        foreach($records AS $key => $record) {
          $user = user_load($record['uid']);
          $emailadresses[] = $user->mail;
        }
      }
    }

    $form['txt_to_addrs']['#default_value'] = implode("\n", $emailadresses);
    $form['fld_subject']['#default_value'] = t('My title !nid - !title', array('!title' => $node->title, '!nid' => $node->nid));
    $form['txt_message']['#required'] = false;
  }
  return $form;
}
jcnventura’s picture

Status: Active » Fixed

#1 for @beyond67: no there is no way to do that. The module sends all e-mails separately to each address, so a cc: or bcc: are indistinguishible from the original to:.. However what you're asking is to be able to add somewhere in the configuration page a list of addresses that will also receive the e-mail.. This wouldn't be complicated to do, but the module doesn't do it.

#2 for johnv: you're code is specific to your needs. This has no way to be part of the module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.