Add Bcc to all emails in WordPress

add_filter( 'wp_mail', 'wpcb_add_bcc_to_all_emails' );
if ( ! function_exists( 'wpcb_add_bcc_to_all_emails' ) ) {
    /**
     * wpcb_add_bcc_to_all_emails.
     *
     * @see https://wpcodebook.com/snippets/add-bcc-to-all-emails-in-wordpress/
     */
    function wpcb_add_bcc_to_all_emails( $atts ) {
        if ( ! isset( $atts['headers'] ) ) {
            $atts['headers'] = '';
        }
        $atts['headers'] .= 'Bcc: ' . 'email@example.com' . "\r\n";
        return $atts;
    }
}

You can add this snippet to your (child) theme's functions.php file.

No comments yet.

Leave a Reply