A fresh mix of code snippets and tutorials

In this WP-Mix post, we’ll see how to send spammers on a virtual infinite loop chasing down randomly generated email addresses. It’s very satisfying.

When a spammer visits your site to harvest your emails, it basically records anything that “looks” like an email address. For example, “anything@anywhere.com” contains all the requisite parts, so it’s considered to be an email address. And harvesters record as many as they can get to add to their scummy mailing lists. I.e., spam.

What this PHP script does is automatically generate thousands of random email addresses whenever it is accessed. So visiting the file in your browser, you’ll see the same thing that a harvester will see: thousands of email addresses ripe for the plucking. Only these emails are bogus, leading the spammers on a wild goose chase that consumes their resources, drains their bandwidth, dilutes their potency, and ultimately costs them time and precious money. Punishment fits the crime is an understatement.

Infinite loop trap

Create a blank PHP file named “emails.php” or whatever, and upload to the directory of your choice. Inside the file, include the following script:

Things to edit: the number of emails to generate. Other aspects may be fine-tuned as well. Optionally you can include a line in your site’s robots.txt file that explicitly forbids access of your email trap: