Drupal: Block Comment Spammers By eMail Country

Recently over at the site we’ve been being hit by comment spammers creating fake accounts and trying to make posts. They aren’t very smart because the fake accounts they create have names of randomly generated letters and numbers that stand-out like sore-thumbs. They also always use fake email addresses so they can never validate their accounts (and thus are never able to post anything). But the really stupid thing is that they always use a .CN (China) domain in their fake email addresses.

I had been manually deleting these accounts but after doing this 300 or 400 times I decided I had better things to do (like watching The Office) so I found a way to permanently block these particular spammers altogether by creating a Drupal Access Role to block all email address that end in .CN .. Now I know what you’re saying – you’re saying “But Randy, what about all your Chinese members?!” – Well, they’re just going to have to buck-up and get GMail accounts. It’s sad how just a few dirty spammers can ruin it for an entire country. Block Chinese comment spammers

How To Create an Access Control Rule In Drupal:

It’s really pretty simple. In the Administration menu find Access Control, then Access Rules and hit Add Rule.

For the type select “Deny”, and rule type select “e-Mail”. Then in the Mask field, enter:

%.cn

% is a wildcard, and the .cn is the TLD for China.. You could replace the % with “_” to mask out particular characters or use just about any combination to block out just about anything you want.

That’s how I was able to block all the dirty Chinese spammers in less than 40 seconds and go back to watching the adventures of Michael Scott, Jim and Pam

3 thoughts on “Drupal: Block Comment Spammers By eMail Country

  1. I use a module that allows me to automatically delete user account after X weeks if they have never loggued in. So I don’t have to manually delete them. Mine don’t always come from china, but yes they never seem to confirm. In fact on this site I moderate new members, so I have to review them, but I let my module take care of deleting the bogus ones later, because as long as they’re in the system, they can’t join with the same user name / email.

  2. Greetings all,
    Just another thumbs up for Drupal, I too love the huge box of leggo.
    Comment spam drives me up the wall, and your right with the generated names etc, apart from sticking out like the you know what on the dogs …. the content of the spam is equally intelligent.
    With many sites to admin, I sometimes feel like taking spammers out for a fish on a short jetty.

    Cool blog and my first visit πŸ™‚

    Have a B L O G G I N G good day!

Leave a Reply

Your email address will not be published.