# Block Disposable Emails in Mailchimp for WP Forms

> Refuses newsletter signups from throwaway email domains in Mailchimp for WordPress forms, keeping your audience clean and your Mailchimp bill lower.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: mailchimp, validation, spam
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/mc4wp-block-disposable-emails/

## Code

```php
$wpide_blocked = array( 'mailinator.com', 'yopmail.com', '10minutemail.com', 'guerrillamail.com', 'tempmail.com', 'trashmail.com', 'getnada.com' );
$wpide_message = 'Please use a permanent email address.';

add_filter( 'mc4wp_form_errors', function ( $errors, $form ) use ( $wpide_blocked ) {
    $data   = is_object( $form ) && isset( $form->data ) ? (array) $form->data : array();
    $email  = isset( $data['EMAIL'] ) ? strtolower( (string) $data['EMAIL'] ) : '';
    $domain = substr( (string) strrchr( $email, '@' ), 1 );

    if ( $domain && in_array( $domain, $wpide_blocked, true ) ) {
        $errors[] = 'wpide_disposable_email';
    }

    return $errors;
}, 10, 2 );

add_filter( 'mc4wp_form_messages', function ( $messages ) use ( $wpide_message ) {
    $messages['wpide_disposable_email'] = $wpide_message;

    return $messages;
} );
```

## Notes

Add domains to $wpide_blocked. The error text can be changed in $wpide_message.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Block Disposable Emails in Mailchimp for WP Forms" 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/
