So it’s important to ensure that both your clients and customers can contact you efficiently and email is one of the most common ways that they can do this. What gets frustrating is posting your email address on a webpage or a contact page, only to find that soon after, you are bombarded with spam and email junk.
I got tired of constantly cleaning out my inbox – 95% of which was purely spam. While my Mail Client can spot and capture a good amount of this, other devices like my iPhone doesn’t seem to block anything in comparison so I have to constantly clean up by phone spam regularly.
Fighting spam effectively will depend on how spam actually works in the first instance. Typically, spam bots crawl the web, page-by-page, specifically looking for email addresses and usually in the standard form of
<a href="mailto:email@email.com">...</a>
…and soon after start spamming you with adverts for fake handbags, enlargement pills and everything else you typically don’t need. A solution as an alternative of the conventional email address link on the page with an <a> tag, you can simply use this snippet below in it’s place and whie the email is printed on the page correctly on the front-end in the normal way, it uses Javascript to rewrite the email address – including the ‘mailto’ address – to help reduce spam. We see this email address just fine on the page, but spam bots won’t.
<script language="JavaScript">
var username = "[info]";
var hostname = "[mydomain.com]";
var linktext = username + "@" + hostname ;
document.write("<a href='" + "mail" + "to:" + username + "@" + hostname + "'>" + linktext + "</a>");
</script>