繁体   English   中英

使用 bcc 和 wp_mail 发送电子邮件

[英]Sending emails with bcc and cc with wp_mail

我想将以下字段发送到 wp_mail

在此处输入图片说明

如果我把所有的电子邮件, Email toCopy toBcc to阵列中的$emails ,并把它传递给wp_mail。 如何在 wp_mail 中设置 cc 和 bcc 的标题?

$headers = 'From: Test <info@test.co.uk>' . '\r\n';
$headers.= 'Content-type: text/html\r\n'; 
$success = wp_mail( $emails, $subject, $message, $headers );  

您可以使用数组发送您需要的所有信息,因此:

$headers[] = 'From: Test <info@test.co.uk>';
$headers[] = 'Cc: copy_to_1@email.com';
$headers[] = 'Cc: copy_to_2@email.com';
...
$headers[] = 'Bcc: bcc_to_1@email.com';
$headers[] = 'Bcc: bcc_to_2@email.com';
$success = wp_mail( $emails, $subject, $message, $headers );  

您可以通过编程方式获得它,在将它们用您在内部字段文本中声明的逗号拆分后,成为所述表单字段的$copy_to$bcc_to数组,并定义了数组$headers

$headers[] = 'From: Test <info@test.co.uk>';
foreach($copy_to as $email){
    $headers[] = 'Cc: '.$email;
}
foreach($bcc_to as $email){
    $headers[] = 'Bcc: '.$email;
}
$success = wp_mail( $emails, $subject, $message, $headers );  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM