Is there a way to hook into the wp_mail function to add a custom email as hidden (BCC) copy to each email sent?

If so, how?


It's not like I want to send an email with BCC, I would like to make the necessary hooks to add the BCC to every sent email (many different functions in my theme make use of wp_mail)

  • Please search the site before asking. Thank you. Also always show your research and what you've tried to prevent down votes closing it down either as duplicate or as "too broad" or "unclear what you're asking". – kaiser Dec 19 '13 at 21:13
  • @kaiser Its not the same question, he wants to add bbc to one custom email, I want to hook the function to add bbc to ANY sent email... – Toni Michel Caubet Dec 20 '13 at 13:20
  • First: You already got a chance to fix your question. You didn't file an edit. Luckily it's not over yet: edit the question, clear out the difference (and show what you've tried) and cast a reopen vote. If it's a good question afterwards it will be reopened. Also: Search the site. There're dozens of questions that show you how to use the phpmailer_init and wp_mail filters. Combine that with the other question args and Bcc part and actually try something yourself and tell us where you failed. – kaiser Dec 20 '13 at 14:57
  • "I Dont think its an exact dupicate" ... please don't edit what you think differs your question from another one. Just write a good question that has everything explained on How to Ask. Thanks. – kaiser Dec 20 '13 at 16:52
  • Just to be clear, are you talking about BCC (with two Cs), as in Blind Carbon Copy - or do you want to make BBQ? SCNR. If the former is the case, did you see my answer below? – tfrommen Dec 20 '13 at 17:29

You have multiple options:

  1. The function is pluggable (i.e., you could write up your own wp_mail function and make it do what you'd like).
  2. There's the phpmailer_init hook, which gives you access to the $phpmailer object (and thus lets you AddBcc another email address.
  3. There's the wp_mail hook, which gives you (amongst other things) access to $headers, where you could add another email address to the 'bcc' field.
  • Thank you for you anser, I will investigate the options, as I'm not sure where to start yet! – Toni Michel Caubet Dec 21 '13 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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