HTML: E-mail Address Linking & Spam Protection

In this post we’ll look at how to link to e-mails with the <a> HTML tag and also how to define a predetermined subject and body text when I user clicks on the e-mail link.  I will also show a solution to preventing spam being sent to any e-mail address linked to.

 HTML Code to Link to an E-mail Address

<a href = “mailto:name@maildomain.com”>
Click to send me an e-mail text
</a>

 

Result:
Click to send me an e-mail text

Adding a Subject and Body Text

<a href = “mailto:name@maildomain.com?subject=Subject Title&body=Here is some body text.“>
Click here to see the results
</a>

Here’s a breakdown of the code:

?subject=Subject Title – ?subject is code you need to activate and “Subject Title” is the text content you want to show under subject.

&body=Here is some body text – &body= activates that we also want to include some body text, which in this example is “Here is some body text”.

Result:
Click here to see the results

 

Protecting Against Spam

A major problem with linking to an e-mail address online is that it becomes the target of spammer’s web crawlers, who pick up your address on the website and used it to send spam.  However, you can prevent the majority of spammers abusing your e-mail link simply by the use of a encoder in HTML.  Just type email address encoder into a search engine and you will find a number of services online that will provide you with an encoded string.  The one form of encoder converts the e-mail address into ASCII character elements to through web crawlers off:

name@maildomain.com converts into:
&#110;&#097;&#109;&#101;&#064;&#109;&#097;&#105;&#108;&#100;&#111;&#109;&#097;
&#105;&#110;&#046;&#099;&#111;&#109;

 

This code is place in the <a> tag in place where the e-mail address would normally be, so the code would look like this:

<a href = “&#110;&#097;&#109;&#101;&#064;&#109;&#097;&#105;&#108;&#100;&#111;&#109;
&#097;&#105;&#110;&#046;&#099;&#111;&#109;”>
Click to send me an e-mail text
</a>