safeMail : Anti-Spam Email with Unobtrusive Javascript

If you’ve included your email address in your site then you’d definitely get junk mail that clogs your inbox. The Spam Bots and Spam Crawlers crawl through the web pages constantly and add all the email address they encounter to their lists.

I wanted a perfect solution to keep the Spam Bots away from my email address. I came across several solutions based on Javascript. But none of them was generalized, almost all of them I encountered used Javascript to insert the email address and each address needed to be coded individually. You can find a similar solution from Joe Maller

I wanted a solution that can generate the email address from an obscure form into a valid one on the fly, and thus resulted in safeMail.

The safeMail script uses DOM to scan the page and convert all the matching email entries into valid email links.

All you’ve to do is to download the ‘safeMail.js‘ file and include it in the header of the page where you’ve got one or more email address. The format you need to define the email address is,

	 yourname [at] gmail [dot] com

The script will replace this as ,

View the safeMail in action

If the browser does not support Javascript or if the user has disabled Javascript the email address will be in accessible format.

You are free to modify this code and please link back to this page. If you’ve any suggestions or found any errors or facing any problem in implementing the safeMail, post it in the comments and I’ll be very glad to help you. If you find a better solution please share it with me :)

2 thoughts on “safeMail : Anti-Spam Email with Unobtrusive Javascript”

  1. this trick is easily detectable by bot scripts… it will not help in fact. One would better use some anti-spam software on server side :)
    like google mail for example :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>