我想将以下字段发送到wp_mail
如果我将Email to
,Copy to
和Bcc 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 );
答案 0 :(得分:9)
您可以使用数组发送所需的所有信息,因此:
$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 );