Sending emails with bcc and cc with wp_mail

后端 未结 1 387
醉酒成梦
醉酒成梦 2021-01-02 01:27

I want to send the following fields to wp_mail

\"enter

If i put all the emails

相关标签:
1条回答
  • 2021-01-02 01:53

    You can use an array to send all the info you need, thus:

    $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 );  
    

    You can get it programmatically, being $copy_to and $bcc_to arrays of said form fields after splitting them by the comma you state in the inner field text, and having defined array $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 );  
    
    0 讨论(0)
提交回复
热议问题