# Never Email Certain Addresses or Domains

> Removes addresses and whole domains on your suppression list from every outgoing email, such as bouncing inboxes or people who asked not to be contacted, and skips emails left with no recipient.

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

## Code

```php
$wpide_suppressed = array( 'bounced@example.com', '@old-company.com' );

$wpide_is_suppressed = function ( $recipient ) use ( $wpide_suppressed ) {
    $email = strtolower( trim( preg_match( '/<([^>]+)>/', $recipient, $m ) ? $m[1] : $recipient ) );

    foreach ( $wpide_suppressed as $entry ) {
        $entry = strtolower( trim( $entry ) );
        if ( $email === $entry || ( 0 === strpos( $entry, '@' ) && substr( $email, -strlen( $entry ) ) === $entry ) ) {
            return true;
        }
    }

    return false;
};

add_filter( 'wp_mail', function ( $atts ) use ( $wpide_is_suppressed ) {
    $to = is_array( $atts['to'] ) ? $atts['to'] : explode( ',', (string) $atts['to'] );

    $atts['to'] = array_values( array_filter( array_map( 'trim', $to ), function ( $recipient ) use ( $wpide_is_suppressed ) {
        return '' !== $recipient && ! $wpide_is_suppressed( $recipient );
    } ) );

    return $atts;
}, 5 );

add_filter( 'pre_wp_mail', function ( $return, $atts ) {
    return empty( $atts['to'] ) ? true : $return;
}, 5, 2 );
```

## Notes

List full addresses or "@domain.com" entries; CC and BCC headers are not filtered.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Never Email Certain Addresses or Domains" 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/
