Block Hotmail email addresses in user signup

I was recently asked to block users from signing up to a drupal site using a hotmail email address.

To achieve this I wrote a small module that will intercept the validate operation of the user module and add in an extra validation on the mail field of the user registration or edit form.

Create your dot info file:

; $Id$
name = Hotmail Check
description = "Removes the ability to login with a hotmail email address."
core = 6.x

Then create your dot module file: hotmail_check.module

// $Id$
 * @file hotmail_check.module
 * Hotmail Check Module
 * This module removes the ability to login with a hotmail email address.
function hotmail_check_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'validate') {
  // find @hotmail in the email address and return an error if it exists
    if (preg_match('/@hotmail/i', $edit['mail'])) {
      form_set_error('mail', t('E-mail addresses from Hotmail are not allowed.'));

And that is all that is required, so go ahead and install and enable the module, now users get an error if they try and use a or email address to create a user account.


A block is a contiguous set of bits or bytes that forms an identifiable unit of data. The term is used in database management, word processing, and network communication.By visiting this site you can know more about the word block.


Thanks for the input. I don't know how I could have lived without that very valuable insight.

Greetings! I've been reading your blog for a while now and finally got the bravery to go ahead and give you a shout out from Lubbock Tx! Just wanted to mention keep up the great job!

Wow finally got what I need! Actually I created a drupal website for business and numerous users are signing up though their hotmail account! I want to stop this! Going to try this code to block unauthorized signing up through hotmail!

Add new comment