There is nothing worse than having your email inbox fill up spam just after you set it up. You need to post your email address on your blog/webpage so that readers/customers can contact you. How can you prevent the spammers from getting it while allowing legitimate users access? WordPress plugins and scripts that use CAPTCHAs are one way. However, they are not so easy to implement on non-PHP pages. And, some CAPTCHA critics claim they deter legitimate users.
Spambots harvest email address from your webpage’s source file. Spambots don’t have eyes! They look for email addresses in your code such as:
john@mysite.com
One way to cloak an email address is to ‘escape it’ using an encoder. The email address above then becomes:
%6A%6F%68%6E%40%6D%79%73%69%74%65%2E%63%6F%6D
We are not done yet because a browser needs an ‘unescape’ script to reconstitute the email address. It looks like this:
What have I done? I have put the escaped string in a set of quotes, wrapped that inside a built-in unescape() method, and then wrapped it all in a document.write() method.
Lost? Don’t worry. It’s easy. Go to this page and escape your email address. Then, follow the directions on the page or put it between the single quotes here:
You can even escape an entire mailto link.
It will look like this:
Put the code into your template (HTML). Then, your browser will display it like this:
As far as I know, spambots cannot read escape code. Not yet anyway!