One of the most common things I see on so many websites that screams ‘bad practice’ and infuriates the hell out of me is email addresses without any form of Obfuscation.
Firstly I’d ask the question, does it have to be an email, as when it comes to providing a spam-free and easy way for people to contact you, nothing beats the convenience of a simple, web-based email form, so I’d always recommend using one instead of an email address if possible. Having said that, I’m all too aware that this is not always possible, so can appreciate those occasions when using an email address is the only option. However I’ve always considered it to be one of the default rules that when displaying an e-mail address on a website you obviously want to obfuscate it to avoid it getting harvested by spam-bots, but maybe a lot of web designers don’t think about this or at least don’t know how to go about creating email obfuscation.
If you fall into the latter category then don’t worry as it’s really not that hard, so to help anyone who doesn’t know how to hide an email address from those nasty spam-bots, I’m posting this handy guide.
The ROT13-algorithm is an encoding method whereby all alphabetic characters are rotated by 13. Similarly, ROT5 is used to encrypt numeric digits, whereby every number is incremented or decremented by 5. This type of cipher is commonly used in Usenet/chat threads.
If we entered a test email address (email@example.com) for demonstration purposes into the online tool, it would encode our example email address, and the output we would get is this:
document.write("<n uers=\"znvygb:firstname.lastname@example.org\" ery=\"absbyybj\">Fraq n zrffntr</n>".replace(/[a-zA-Z]/g,
<a href="mailto:email@example.com" rel="nofollow">Send a message</a>
..which will create an email link on the page for all of your visitors to use.
Hopefully this post will have helped to give a better understanding of how to hide email addresses from spam-bots, and while if you have the time, I’d always suggest using a web-based email form for contact pages, if you just need a way to simply include an email address, my suggested method for email obfuscation will hopefully do a great job at for keeping your publicly displayed emails spam-free.