Bcc in WordPress Mail

I was constantly getting the queries regarding how to add multiple recipients to a WordPress mail. So here at Templatetoaster WordPress website builder, I have tried to give a simple but elegant solution to Cc, Bcc in WordPress mail.

Email is one of the instant tools for business communication. It can be sent to multiple people for collaboration. Messages move quickly and lots of information can be shared in the body of the email. An email provides you different fields to add the recipients with the distinct motives. For example To, Cc, Bcc.

  • To is for Intended Actionable Recipients.
  • Cc (Carbon Copy) is for people you want should know about the message without any direct involvement. Added only to keep informed. The receiver comes to know about all the persons who are receiving email through Cc.
  • Bcc (Blind Carbon Copy) is used when you want to send an email to others but without knowledge of other recipients.

In the case of WordPress too, you need to send the same email to multiple recipients. All the available plugins to Cc, Bcc in WordPress mail are now obsolete. So, you can simply use the following code to add Cc, Bcc in WordPress mails. Simply paste this code in “functions.php” file of your theme and replace the example mail ids with your mail ids.

For adding Cc & Bcc

add_filter('wp_mail','custom_mails', 10,1);

function custom_mails($args)
{
$bcc_email = '[email protected]';
$cc_email = '[email protected]';
if (is_array($args['headers'])) {
$args['headers'][] = 'Bcc: '.sanitize_email($bcc_email );
$args['headers'][] = 'cc: '.sanitize_email($cc_email);
}
else {

$args['headers'] .= 'Bcc: '.sanitize_email($bcc_email )."\r\n";
$args['headers'] .= 'cc: '.sanitize_email($cc_email)."\r\n";
}
return $args;
}

For adding Cc Only

add_filter('wp_mail','custom_mails', 10,1);

function custom_mails($args)
{
$cc_email = '[email protected]';
if (is_array($args['headers']))
{

$args['headers'][] = 'cc: '.sanitize_email($cc_email);
}
else
{
$args['headers'] .= 'cc: '.sanitize_email($cc_email)."\r\n";
}
return $args;
}

For adding Bcc Only

add_filter('wp_mail','custom_mails', 10,1);

function custom_mails($args)
{
$bcc_email = '[email protected]';

if (is_array($args['headers'])) 
{
$args['headers'][] = 'Bcc: '.sanitize_email($bcc_email );
}
else 
{
$args['headers'] .= 'Bcc: '.sanitize_email($bcc_email )."\r\n";
}

return $args;
}

Now, you have a simple and small easy script that will work out well in WordPress. Also, I am planning to write an article to create a plugin for Cc, Bcc in WordPress mail soon. Your feedback is always valuable. So please share your views.

So this was all about how to add Cc, Bcc in WordPress mail but if you are still looking to setup your own SMTP for WordPress, check out this article. Moreover, if you are all done with Mail configuration and thinking to give your site a makeover, start designing with TemplateToaster web design software and website maker. Free WordPress themes are also available.