# 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.

- Type: PHP
- Runs: Run everywhere
- Category: [Email](https://wpide.com/library/category/email/)
- Tags: email, bcc, archive, logging
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/email-bcc-archive/

## Code

```php
add_filter( 'wp_mail', function ( $atts ) {
    $archive = ''; // For example 'archive@yourdomain.com'.

    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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Copy Every Outgoing Email to an Archive Address" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
