Title: Block specific domain
Last modified: June 13, 2022

---

# Block specific domain

 *  [erossini](https://wordpress.org/support/users/erossini/)
 * (@erossini)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/block-specific-domain/)
 * I have a problem with my blog because a lot of emails are sent to one of these
   emails (different account some domain):
    - gemmasmith.co.uk
    - jenniferlawrence.uk
    - b-mail.online
    - katykahn.co.uk
    - sarahconner.co.uk
    - marymarshall.co.uk
 * I don’t understand why the blog is sending all those emails. So, I tried to block
   the registration for those domains. First, I added in the function.php of the
   theme the following code
 *     ```
       // prevent user registration in wordpress from specific domain
       function wpcs_disable_email_domain ( $errors, $sanitized_user_login, $user_email ) {
           list( $email_user, $email_domain ) = explode( '@', $user_email );
           if ( strpos($email_domain, 'b-mail.online') != false || 
       		 strpos($email_domain, 'dynainbox.com') != false || 
       		 strpos($email_domain, 'gemmasmith.co.uk') != false ||
       		 strpos($email_domain, 'marymarshall.co.uk') != false ||
       		 strpos($email_domain, 'katykahn.co.uk') != false || 
       		 strpos($email_domain, 'roastedtastyfood.com') != false
       	) {
               $errors->add( 'email_error', __( '<strong>ERROR</strong>: Domain not allowed.', 'my_domain' ) );
           }
           return $errors;
       }
       add_filter( 'registration_errors', 'wpcs_disable_email_domain', 10, 3 );
       ```
   
 * but the emails are still sending. Then, I tried different plug-in like Ban Hammer
   or WP Security. Nothing.
 * Could you help me to understand how to block all those emails to these domains?
 * Thank you advance,
    Enrico
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fblock-specific-domain%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [George Appiah](https://wordpress.org/support/users/gappiah/)
 * (@gappiah)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/block-specific-domain/#post-15734021)
 * What are these emails?
 * Please examine the emails critically (including the email’s header).
 * 1) Are they normal WordPress registration emails? Or spam from your contact form?
 * 2) Are the emails even originating from your server? Or is your domain merely
   being spoofed?
 *  Thread Starter [erossini](https://wordpress.org/support/users/erossini/)
 * (@erossini)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/block-specific-domain/#post-15734027)
 * Thank you for your reply.
 * Definitely the emails are from my mail server. This is an example
 *     ```
       This message was created automatically by the mail system (ecelerity).
   
       A message that you sent could not be delivered to one or more of its
       recipients. This is a permanent error. The following address(es) failed:
   
       >>> beatriz_arek59@gsa4.gemmasmith.co.uk (while not connected): 554 5.4.5 [internal] Delivery not attempted (message expired)
       ```
   
 *  [George Appiah](https://wordpress.org/support/users/gappiah/)
 * (@gappiah)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/block-specific-domain/#post-15734041)
 * This message is merely the notification of a failed email. As you noted, this
   is from your mail server, and nothing to do with WordPress.
 * But what’s in the ORIGINAL email that was to be sent that couldn’t be delivered?
 * Is that a WordPress registration email?
 *  [olomosis](https://wordpress.org/support/users/olomosis/)
 * (@olomosis)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/block-specific-domain/#post-16164154)
 * Dear Team,
 * I have also been experiencing the same issues. Below is one of such messages:
 * This message was created automatically by mail delivery software.
 * A message that you sent could not be delivered to one or more of its recipients.
   This is a permanent error. The following address(es) failed:
    [marylou_leavens@ax101-7.gemmasmith.co.uk](https://wordpress.org/support/topic/block-specific-domain/marylou_leavens@ax101-7.gemmasmith.co.uk?output_format=md)
   all hosts for ‘ax101-7.gemmasmith.co.uk’ have been failing for a long time (and
   retry time not reached)
 * When i checked the request message header, it was requesting my ‘site login details’
   
   How can i block this specific domain from registering or accessing the sit?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Block specific domain’ is closed to new replies.

## Tags

 * [block](https://wordpress.org/support/topic-tag/block/)
 * [email](https://wordpress.org/support/topic-tag/email/)
 * [Registration](https://wordpress.org/support/topic-tag/registration/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [olomosis](https://wordpress.org/support/users/olomosis/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/block-specific-domain/#post-16164154)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
