I created a function which returns an array of email addresses:

// returns all wanted email adresses

This is the given array:

    [0] => [email protected]
    [1] => [email protected]

How can I add this emails to the headers array that it looks like this?

function leweb_send_mail_to_author() {

    $to = leweb_get_events_detail();
    $subject = 'The subject';
    $body = '<strong>The email body content</strong>';
    $headers = array('Content-Type: text/html; charset=UTF-8','From: Owner <[email protected]>', 'BCC:[email protected]', 'BCC:[email protected]');

    wp_mail( $to, $subject, $body, $headers );

1 Answer 1


You'd write them the same way you would any other email, the knowledge you need to do this is Email header knowledge, not WP knowledge. Those are raw email headers, and aren't a special WP format.

Since each item in the array is a line in the header of the email, we need to know how an email client writes out a BCC line.

This article describes all the various headers: https://mailformat.dan.info/headers/from.html

We can also get an example of specifying multiple emails in a header field by looking at the headers in any Email client. For example, here's a header field for an email I recieved from Github:

Cc: Tom J Nowell <[email protected]>, Author <[email protected]>

I got this in gmail by using the 3 dot dropdown and clicking show original. You won't see a BCC field this way, but given that multiple emails are always specified the same way, I trust you can make the minor leap and reuse the same format in the BCC field. E.g.

    $headers = [
        'Content-Type: text/html;'
        'Cc: Tom J Nowell <[email protected]>, Author <[email protected]>',

    wp_mail( $to, $subject, $body, $headers );

I trust you can make the final adjustment yourself, I won't cover looping over an array of strings and joining them together as that's basic PHP that I trust you can handle

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.