【问题标题】:How to set multiple CC email recipients one message using webform in drupal 7如何在 drupal 7 中使用 webform 设置多个 CC 电子邮件收件人一封邮件
【发布时间】:2017-03-30 12:35:36
【问题描述】:

我的网站在 drupal 7 应用程序中使用 webform。

我有两个问题

  1. 我可以为一封邮件添加到电子邮件收件人列表。电子邮件将接收所有收件人,但发送个人的邮件。我在 to list 组中看不到。

  2. 如何设置多个抄送电子邮件收件人一封邮件?这里在“$headers”下的 theme_mail_headers 中使用 'CC' => 'xx@yyyy.com, xx1@yyyy1.com, xx2@yyyy2.com'。

【问题讨论】:

    标签: email webforms drupal-7 cc


    【解决方案1】:
    function MODULENAME_mail($key, &$message, $params) {
        if($key === 'MODULEcase') {
            $header = array(
                'MIME-Version' => '1.0',
                'Content-Type' => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
                'Content-Transfer-Encoding' => '8Bit',
                'X-Mailer' => 'Drupal',
                'Cc' => implode(',', $params['Cc']),  
            );
            $message['subject'] = $params['subject'];
            $message['body'][] = $params['body'];
            foreach ($headers as $key => $value) {
                $message['headers'][$key] = $value;
            }
            break;
        }
    }
    
    Then prepare data and pass to drupal_mail function
    $mail_content = "Hello There!";
    $params = array('body' => $mail_content);
    $params['cc'] = array(
        'cc_user1@example.com',
        'cc_user2@example.com',
        'cc_user3@example.com',
    );
    $to =  'touser@example.com';  
    $from = 'no-reply@example.com';
    $mail = drupal_mail('MODULENAME', 'MODULEcase', $to, language_default(), $params, $from);
    
    This is it. Enjoy :-)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-30
      • 1970-01-01
      • 2019-04-26
      • 2016-05-08
      相关资源
      最近更新 更多