Foiling the Email Spambots

Wired magazine has a recent article entitled How to Hide Your Email Address from Spambots. They give some popular and effective approaches, but even having the words “contact me” in the source of your page (instead of the word “email”) can easily be caught by the spambots, and you never want an actual mailto: link in your source code.

I’d like to suggest a similar, but in my opinion simpler and equally effective alternative to the solutions they provide:

  • Use an onmouseover javascript function to break up your email address in your page’s source, but to re-assemble it when the link is clicked. Very easy, very effective.
  • Make the link a picture, not words. No keywords for the ‘bots to catch, so you don’t have to worry whether they’ll notice “contact me”, “email me” or anything similar.

This is exactly what I’ve done in my sidebar for years, and so far it’s been 100% spam-proof. Wish I could say the same for comment spam on the blog!

You’ll have to decide what you want on the image, but make it really obvious that it’s an email link. Once you have that, here’s how the code looks. It simply goes in your HTML source where the dreaded malito: link was before. Note that there’s a “fallback” a href link to your website in case the user’s computer doesn’t do “onmouseover” (if it doesn’t, they’ve got much bigger headaches than having trouble sending you mail):

<a href=”your website’s url here (NOT your email address)” onmouseover=”this.href=’mai’ + ‘lto:’ + ‘email address before the “at” sign‘ + ‘@’ + ‘email address after the “at” sign; i.e. gmail.com‘”><img
src=”link to your image here” border=”0″ alt=”Send Me Mail!” /></a>

For example, if your email address is you@yourdomain.com and the link to your contact image is http://www.yourdomain.com/images/contact.gif, the code would be this:

<a href=”http://www.yourdomain.com” onmouseover=”this.href=’mai’ + ‘lto:’ + ‘you‘ + ‘@’ + ‘yourdomain.com‘”><img
src=”http://www.yourdomain.com/images/contact.gif” border=”0″ alt=”Send Me Mail!” /></a>

The hardest part of this process for me was fooling around with the images, trying to come up with one I liked. Decisions, decisions!


Comments are closed.