Have you ever wanted to deny access to all users with a certain e-mail address? Or, better yet, have you ever wanted to only allow users with @institution.edu to create accounts on your site? Below an easy solution using Drupal's access rules.

View your access rules by going to Administer -> Access Control -> Access Rules.

Click on Add Rule and add the following e-mail rules:

  • Deny %@% (which blocks all e-mail address)
  • Allow %@institution.edu (which will allow people with anyone@institution.edu)

When you're done go and check your rules by clicking on "Check Rules." (Drupal 5)

Comments

dccrane’s picture

Drupal 6.15.

deny email %.@%.ru when tested says it's allowed. Furthermore, xxx@mail.ru was allowed.

What am I missing?

dccrane’s picture

Sorry for the typo. The rule is %@%.ru

bibliotastic’s picture

Is the rule checker wrong or is the access rules function actually not working?

Drunoober’s picture

as written in the doc you need to...

set Deny %@% (which blocks all e-mail address)

AND THEN

Allow %@institution.edu (which will allow people with anyone@institution.edu)

in simple terms you need to start from the most restrictive rule and add exceptions to that restriction

Hope this helps

RIEntrepreneur’s picture

I got the access rules working to only accept a certain domain. How can I make a custom access denied or page redirect when users are denied registration due to their email.

Anonymous’s picture

Hi,

Is there a way to do this in Drupal 7? would be very grateful for any explanation. Is there a way to do this with the rules module / how?
thanks!!

eusofzay’s picture

chefarov’s picture

Hello

I have used this method to permit access only for emails of specific domain, and I have created allow rules for some accounts already registered that I do not want to lock out...

But somehow the deny rule becomes global without taking care the allow rules and I have locked out some users, maybe admin will also be after my session expires.

Any Ideas?

chefarov’s picture

Finally it was due to the fact that when you make a deny rule based on email, then you should make an allow rule also for email so that to add an exception for some users. I was doing that by username allow rule which doesn't work.

DooDoo’s picture

In Drupal 7, where to set access rule ?

I used to set it in Drupal 6 . when I upgrade to Drual 7, I could not find it.

z8ballbaby’s picture

I administer a private local group website and get 50-100 spam registers every day. If I add a rule to the spam email, they just get blocked and I still have to take time to delete them. Then they just re-register again.

Is there a way to not allow a domain (like ".com.br") to even attempt to register?