我正在尝试将密件抄送添加到 woocommerce / wp 发送的每封邮件中。我尝试使用在网络和 Stackoverflow 上找到的不同解决方案,并将片段添加到我正在使用的主题的functions.php中:
add_filter( 'woocommerce_email_headers', 'add_bcc_to_wc_admin_new_order', 10, 3 );
function add_bcc_to_wc_admin_new_order( $headers = '', $id = '', $wc_email = array() ) {
if ( $id == 'new_order' ) {
$headers .= "Bcc: my@mail.net\r\n";
}
return $headers;
}
Run Code Online (Sandbox Code Playgroud)
和
add_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 2);
function add_bcc_all_emails($headers, $object) {
$headers = array();
$headers[] = 'Bcc: my@mail.net';
$headers[] = 'Content-Type: text/html';
return $headers;
}
Run Code Online (Sandbox Code Playgroud)
和
add_filter('wp_mail','custom_mails', 10,1);
function custom_mails($args){
$bcc_email = sanitize_email('my@mail.net');
if (is_array($args['headers'])){
$args['headers'][] = 'Bcc: '.$bcc_email ; …Run Code Online (Sandbox Code Playgroud)