As we all know spam is a plague that has spread to every far corner of the Internet. Spam-bots collect our email addresses in many ways, but in my opinion the most likely way they’ll get your email address is from scraping webpages such as forums, where you email may be listed. So when you’re building your site and you want to put an “email me” link you should be very careful about doing so. Once the bots find it they’ll start sending you endless offers to buy Viagara an Cialis.
So what can you do to stop this? There are many solutions! But today I want to offer you a simple JavaScript file that will encrypt your all email addresses on your page automatically. It can be downloaded from Voynex, however they don’t really offer a good explanation on how to use it. So here is a step by step:
- Download the Email Guard script from Voynex’s site
- Extract the files and upload xmailguard.js to your site, I usually have a directory called “scripts” in the root of each site
- In any page you want to have your emails encrypt link the script by adding this line to the top: <script language=”javascript” type=”text/javascript” src=”/scripts/xmailguard.js”></script>
- Initialize the script by adding another script block : <script language=”javascript” type=”text/javascript”>xmgInit()</script>
- Now you have to type your email links a bit differently, instead of <a href=”mailto:email@address.com”>email@address.com</a> you will have to code your links to <a href=”mail_to_email_at_address.com”>email_at_address.com</a> and when the page loads it will rewrite them for you. If you are using PHP this line will do most of the work for you: $email = str_replace(“@”, “_at_”, $email);
- Now its possible that some bots will render the javascript first before doing their dirty work, but from my experience I have found they don’t process the javascript. You can also customize the encrypted syntax you want to use by tweaking the first couple of lines in xmailguard.js
Now your email addresses are safe!
A seasoned Senior Solutions Architect with 20 years of experience in technology design and implementation. Renowned for innovative solutions and strategic insights, he excels in driving complex projects to success. Outside work, he is a passionate fisherman and fish keeper, specializing in planted tanks.