Fresh Blurbs

Spam-Free Mailto Link

By now, we've all learnt that simply putting a link to your e-mail address on a website means exposing yourself to spammers. Bad idea! For this reason, contact forms with captcha are often used instead. But sometimes we do want to display an e-mail address.

What to do?

Well, security through obscurity may not be 100% reliable but still helps. Some people take it too easy and write something like: smartypants AT yahoo dot com. First of all, it is not user-friendly. It is not a link you can click and send e-mail from. Do you expect your users to be deciphering it? Secondly, I am sure most spam bot algorithms can decipher it by now quicker than humans.

So, here is a little more sophisticated obsfuscation which renders proper link and has been working quite well for me, so far:

<script type="text/javascript" language="JavaScript">
    var atChar = "@";
    var obf_eml = "i"+"n"+"f"+"o";
    obf_eml += atChar;
    obf_eml += "i"+"bm"+".com";
</script>

<!-- Anywhere further in HTML: -->
<script type="text/javascript" language="JavaScript">
    document.write ( "<a href=\"mailto:"+obf_eml+"\">"+obf_eml+"</a>" );
</script>

Example:

comments powered by Disqus