我的网站使用webform在drupal7应用。
有两个查询
-
我可以添加一个给收件人发邮件的列表。电子邮件将接收所有收件人,但邮件发送个人。
-
如何设置一个邮件的多个抄送收件人?这里我使用'CC' => 'xx@yyyy.com, xx1@yyyy1.com, xx2@yyyy2.com'在theme_mail_headers下的"$headers.
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 :-)