[英]Drupal simple mail sending with cc and bcc
I have gone through the drupal_mail function and written the below code. 我已经通过了drupal_mail函数并编写了以下代码。 It is sending the mail but without the subject and Body of mail.
它正在发送邮件,但没有邮件的主题和正文。
Can anyone tell me why is it so. 谁能告诉我为什么。 Other part is how can I add CC and BCC in mail?
另一部分是如何在邮件中添加抄送和密件抄送?
Gone through this but they have not used drupal_mail in answer 走过了这个 ,但他们并没有用于回答drupal_mail
$params = array(
'body' => 'plain text mail',
'subject' => 'Join this Event',
);
if(drupal_mail('join_this_event', 'some_mail_key', "ansari@infiniti-research.com", language_default(), $params, "noreply@test.com", TRUE)){
echo "mail sent";
}
else echo "unable to send";
Everything you need is in the email message headers array. 您需要的所有内容都在电子邮件标题数组中。
$params['headers'] = array(
'Bcc' => 'bcc_email@example.com',
'Cc' => 'cc_email@example.com',
);
Here is an example implementation of drupal_mail() with bcc headers included. 这是带有bcc标头的drupal_mail()的示例实现。
$params = array(
'body' => $body,
'subject' => $subject,
'headers' => array(
'Bcc' => $header_bcc,
'Cc' => $header_cc
)
);
$email = drupal_mail('ModuleName', 'message_key', $to, LANGUAGE_NONE, $params, $from, true);
Using hook_mail(): 使用hook_mail():
/**
* Implements hook_mail().
*/
function ModuleName_mail($key, &$message, $params) {
switch ($key) {
case 'message_key':
$message['headers'] += $params['headers'];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.