Prevent spam by encoding your email addresses
Posted on 01. Aug, 2009 by Guillermo in Development
Prevent spam by encoding your email addresses
If you have your email published on your (or any other) site, and this site is being indexed by search engines, eventually you will end up with a mountain of spam in your inbox.
Why is this you ask? Basically “spam bots” as they are called, are gathering email addresses from the internet, they work by using the search engines to find and look through sites, getting every email address they see. To fight the spam bots we need a way of preventing these little guys from taking our addresses while of course leaving a way for our visitors to see them.
A simple approach
This approach is widely used although not the safest ( much better than just typing your address as it is of course).
Here is how its done, when writing the email address we change it a bit. Example:
info [at] domain.com
myemail (at) domain.com
This leaves it still readable by humans although a little less bot friendly. You can vary the form (maybe you like using {} instead), to make it match your style.
Encoding your address
Another approach (my favorite) is to obfuscate the email in the source code, using a javascript code that reconstructs the address on the client side. While this sounds complicated its invisible for the end user and prevents the bots from seeing the address as most can not execute javascript.
Here’s a couple of resources that do that for you (they give you a javascript code based on the address you want to encode):
Rumkin.com Mail encoder: very cool tool, has a lot of options.
MailToEncoder: a simple but powerful encoder we put together as one of our weekend projects
Encode!
Go ahead and encode the addresses you have published on your site, is never too late to fight spam!
Spanish




















602.288.5333
+54 261 4340244
