Advanced Image Spam Protection

Introduction

One of the continuing problems with putting your email on a website is fear of spammers harvesting it. There are a lot of different solutions to this problem, but most of them are either ugly or easily cracked. Here’s a slightly clever and perhaps a little too(?) complicated method of using images to fool robots. The idea is that your address will look normal to humans but like jumbled gibberish to computers. I've used it for a couple of years now without it ever being cracked by a bot.

Single image

Lots of people use a single image, something as simple as , but do to being so common robots can still get around it. To prevent a machine from reading it would require lots of distortion and makes it difficult, or at the least annoying, for humans to understand as well. This is why I’ve devised an easy and foolproof (as far as I know) method to prevent machines from picking up your email, yet humans will never tell the difference.

Multiple images

First create a simple image of your address, like this: . Next cut the image up into segments, like this: , , and . If you post these all together without spaces it will look no different from your base image, and the html code will look like this:

<img src="example1.png" alt=""><img src="example2.png" alt=""><img src="example3.png" alt="">

Now to get even trickier we’ll add extra images in between the four images I just showed you, but we’ll set their style to display:none; and their height and width both to 0. Therefore humans won’t even notice they’re there, but malicious robots will.

Here’s my example code, I just repeated the same images over again because it doesn’t matter what images you use for this part and this is easy and saves bandwidth:

<img src="example3.png" style="display:none;" height="0" width="0" alt=""><img src="example1.png" style="display:none;" height="0" width="0" alt=""><img src="example1.png" alt=""><img src="example3.png" style="display:none;" height="0" width="0" alt=""><img src="example3.png" style="display:none;" height="0" width="0" alt=""><img src="example2.png" style="display:none;" height="0" width="0" alt=""><img src="example1.png" style="display:none;" height="0" width="0" alt=""><img src="example2.png" alt=""><img src="example1.png" style="display:none;" height="0" width="0" alt=""><img src="example3.png" style="display:none;" height="0" width="0" alt=""><img src="example3.png" alt="">

This will appear to humans as: , but robots will see this:

PHP solution

That might seem like a mess, so I’ve tried to help make it easy by writing a php script that automatically generates the code for you. All you need is to save image.php on your site and echo the securemail() function. In the example I gave above you would use <?php echo securemail("lmao@tankadillo.com"); ?> to produce the images.

Here are the files: securemail() function | image generator

Possible downfalls

It’s impossible to create a “perfect” solution to hide your email address, there are simply some methods more effective than others. Right now this method is effective because of it’s obscurity, if a spammer wanted he could easily adjust his bot to get around this. The PHP code I provided divides the email into three strings, if a bot could identify these strings the method would be ruined. This could be fixed by converting the strings to something random like hexadecimal, or adding even more random strings. But even if this is done there’s still the pattern where every “dummy” image has display:none in the style attribute. This could be fixed by using a class attribute combined with a css file instead, but there will always be some possible way for a computer to read it. The best way to protect your email is by making whatever method you use unique. It’s thousands of people using the same technique that causes those techniques to fail.

Also note that I haven’t done anything official to test if this method actually works. However it makes a great deal of sense, and I've been using for a year and haven't received a single spam email through the address I've used. So I think it's safe to say that it works well for me at least. Also, here’s more fun stuff related to spamming .