The days of the mailto: email link should be long gone, but unfortunately there are still millions of those type of links out there. I don’t necessarily mean unfortunately for you or me; I mean unfortunately for the millions of people who are the poor recipients of email from such links out there.

There are thousands of nasty little spambots out there just searching the web hour after hour, zeroing in on that little snippet of code known as a mailto: email link. Bingo, when they find one, the email address that comes immediately after mailto: in the link will be massively bombarded over time with spam. Did you ever really wonder how that poor widow in Nigeria got your email address?

Every good web design company has an even better web programmer. That web programmer can spend up to 1/3 of his or her time just trying to stay one step ahead of the hackers and spammers. In larger companies, it can be a full time job.

The mailto: spam debacle is generally one of the easier problems to troubleshoot, and I’ve seen many different workarounds.

Some people just type out their email address but don’t make it a link. This is fine, but it forces the person who wants to email you to have to write it down, or copy it over to their email program in order to email you. That’s where human error enters the picture.

Some are even afraid to type out their full email address on a web page so they take that human error factor one step deeper and tell people to email them at myname at mysite.com.

Now, I’ve also seen some ingenious workarounds. I’ve seen code that turns typed email addresses into images of the letters because the spambots can’t read text in images. That one is pretty cool!!! But it’s also pretty complicated for the average site.

My favorite solution is a simple javascript, placed in an external javascript page. I’m so fond of it that I’m about to share it with you. Copy and paste the following into your external javascript page, or just in the head area of your page:

<script type=”text/JavaScript”>
<!- –
  function myEmail(prt1,prt2,id,subject){
    //redirect to mailto
    if (subject == undefined ){
      window.location = ‘mailto:’+ prt1 +’@’+ prt2;
    }else{
      window.location = ‘mailto:’+ prt1 +’@’+ prt2 + ‘?Subject=’ + subject;
    }
    return false;
  }
– ->
</script>

Now instead of the mailto: email link in the body of your document use this:

<a href=”javascript:void(0);” onClick=”myEmail(‘myname’,’mysite.com’,this,’Website Contact’);” title=”Click here to email us”>email us</a>

Now how cool is that?! And if you think about it, how much more simple could it be?

Print This Post Print This Post