Created
September 20, 2023 11:31
-
-
Save LaxusCroco/0571a118271fd7112b39f1947eac3313 to your computer and use it in GitHub Desktop.
Send all emails on the site as bcc. To make the snippet work, the subject field of the email should contain <bcc:emails>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wp_mail', function( $args ) { | |
if ( false === strpos( $args['subject'], '<bcc:emails>' ) ) { | |
return $args; | |
} | |
$email = $args['to']; | |
$email = implode( ', ', $email ); | |
$args['subject'] = str_replace( '<bcc:emails>', '', $args['subject'] ); | |
$bcc = $email; | |
$args['to'] = array( '[email protected]' ); | |
$args['headers'] .= "\r\nBcc: " . $bcc; | |
return $args; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment