how to

How to prevent email spam when putting your email address in your website

I’m a web designer who created and manages a fairly large and well-visited directory website promoting the art community in my region, the Southern Oregon Artists Resource, and its companion blog, Art Matters!. Both sites, but particularly the directory site, have a lot of other people’s email addresses in each page, and from the outset I wanted to protect them by obfuscating their email addresses.  I use a script written by James Crooke for this, and use a plugin called “emOba” (for “email obfuscator”) in the WordPress sites I build. Of course, making sure you pay the extra little bit for domain privacy when setting up your website’s domain name is also extremely helpful, and I recommend doing both to protect your identity and reduce the time it takes to manage your inbox.

If you’d like to try the technique I use at soartists.com, first copy this chunk of code and place it in the <head> section of your page:
<script language=”JavaScript” type=”text/javascript”>
// Script Originally by SSI Developer (www.ssi-developer.net)
// Modified by James Crooke of CJ Website Design (www.cj-design.com)

function protectmail(name, address, link, subject, body) {

document.write(“<a href=’mailto:” + name + “@” + address + “?subject=” + subject + “&body=” + body + “‘>” + link + “</a>”);

}
</script>

Then, in the part of the code corresponding to where you would like the email link to appear in your page, place this chunk of code, edited to reflect your own email address and without the line breaks you see here:
<script language=”JavaScript” type=”text/javascript”>protectmail(“webmistress”,”hannahwestdesign.com”, “Click here to email”, “RE: I found you at the Southern Oregon Artists Resource and wanted to ask a question”, “Hello Hannah,”);</script>

You can see there is no “@” in the email address, the key feature that tips off the spambots to an address they should harvest. It also gives you the opportunity (as addressmunger does) to put custom text for the link, custom text in the subject line and a greeting in the body of the email that will pop up when a visitor to your site clicks the link.

There is another service online called addressmunger.com. Nice service, very similar technique, and easy to use for those who want to generate some code to use, but as a web designer who is also concerned about the amount of code in a page that is not readable by good web bots (like Google’s) I think it’s a little code-heavy.