How to Add a BCC To Email Notifications

Introduction

Would you like to add BCC (Blind Carbon Copy) to all of your email notifications? Or maybe on a few select forms? With a small PHP snippet, you can easily achieve this and we’re going to walk you through each step.

Within the WPForms builder, you can already add CC (Carbon Copy) to your email notifications.

In the WPForms settings you can enable the Carbon Copy field on email notifications

If you want to take a closer look at the Carbon Copy option, please see this documentation.

Creating your form

For the purpose of this documentation, we’re going to have the application for employment form send to the head of HR but also the head of the department that’s hiring. So our form will include a Name, Email, Phone, File Upload (for the resume), and a Date field (for the birthday).

Add the fields to your form and move to the next step

If you need help in creating your form, please see this documentation.

Adding the snippet for BCC to email notifications

Now it’s time to add the code snippet. If you need any help in adding snippets to your site, please see this tutorial.

/**
 * Add BCC to Email Notifications.
 *
 * @link https://wpforms.com/developers/how-to-add-a-bcc-to-email-notifications/
 *
 */

function wpf_dev_emails_send_email_data($data, $emails) {
  	 
	// Only run this snippet on the form ID 235
	if ( absint( $emails->form_data['id'] ) !== 235 ) {
	   return $data;
	}
	
		// BCC
		$data['headers'] .= "Bcc: [email protected]\r\n";

		// Add multiple BCC by duplicating the line above and changing the email address
		// EXAMPLE: $data['headers'] .= "Bcc: [email protected]\r\n";

		return $data;

}
add_filter( 'wpforms_emails_send_email_data', 'wpf_dev_emails_send_email_data', 10, 2 );

Remember to change the 235 to match your form ID. If you need help in finding your form ID, please see this tutorial.

Now when your form is completed out, the email notification will be sent to the email address listed in the form builder’s Notifications tab but you’ll also see a BCC for the email added by the snippet.

Now you can see there is a BCC field on the email notifications