Copy Every Outgoing Email to an Archive Address
Adds a hidden BCC to every email the site sends, so you keep a copy of password resets, orders and form notifications in one mailbox.
Opens WPIDE on
Code
add_filter( 'wp_mail', function ( $atts ) {
$archive = ''; // For example '[email protected]'.
if ( ! is_email( $archive ) ) {
return $atts;
}
$line = 'Bcc: ' . $archive;
if ( is_array( $atts['headers'] ) ) {
$atts['headers'][] = $line;
} else {
$atts['headers'] = trim( (string) $atts['headers'] . "\n" . $line );
}
return $atts;
} );
Notes
Set $archive to a mailbox you control. Recipients do not see the BCC address.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.