Email Address Obfuscation
Yes, it is a weird word but it is the proper term and I can't think of another single word that sums it up. We do not want web spyder and bot programs to be able to read our email addresses. This is a common way for spammers to get lists of email addresses and is called "email harvesting". I'll talk about several ways to do this, getting progressively more technical, as well as progressively more secure, not coincidentally.
- "Munging" the Adresss: Not much better work than obfuscation, I know. This is to simply change the text that is displayed for your email address, to something such as "tdurocher at gmail.com", instead the usual "@" sign. This is very easy, but is the least secure because it is not that hard for a bot program to check for common mungings and reconstruct them as email addresses. It also has the disadvantage of forcing users to figure out just what IS your real address. Further, this solution also does not allow for the use of mailto: links since they require the real email address to be written in the anchor tag.
- Using Javascript to dynamically create the email address. In this way, we can display the correct address, but it actually does not appear anywhere in our code, and therefore cannot be found by the bots. For example, a mailto: link would appear as:
<script type="text/javascript">
var emailAddr = 'tdurocher'+'@'+'gmail'+'.'+'com';
document.write("<a href=\"mailto:"+emailAddr+"\""+">");
document.write("Email Here!</a>");
</script>
- The third way also dynamically creates the email address, but using PHP. It has pretty much the same advantages of the Javascript method, but some browsers have turned off Javascript or you may just prefer PHP. In PHP a mailto: link would appear as:
<?php
$emailAddr = 'tdurocher'.'@'.'gmail'.'.'.'com';
echo("<a href=\"mailto:".$emailAddr."\"".">");
echo("Email Here!</a>");
?>
Email Here! - The final, and probably best, way is to use a Contact Form instead of an email address. Since the email address never appears in any form in the server files, there is no possibility of a harvester bot finding it. However, it is fairly difficult to set up and would be the subject of a whole other tip (one of these days...).
-Tom