As a website operator you’re advised to include your email address on your website so that you can easily be contacted by visitors, but should you put your email address on your website? Sometimes it’s even mandatory if you do business within the EU or UK and this is because of the GDPR and UK GDPR. The problem with including your email address is that you could find yourself inundated with spam. So how do you protect your email address on your website from spam and still fulfill your ob­lig­a­tions? We present the most popular methods and explain their ad­vant­ages and dis­ad­vant­ages.

Email har­vest­ing and how spambots stalk their prey

Email har­vest­ing is the automated ac­quis­i­tion of email addresses for unfair ad­vert­ising, phishing attacks, or spreading malicious software. Spe­cial­ised programs (known as ‘email har­vesters’) search websites, mailing lists, forums, or social media platforms for email addresses. They recognise email addresses due to their char­ac­ter­ist­ic features such as the @ sign. More refined spambots can even search for al­tern­at­ive spellings website operators try to get away with such as [at], [AT], (at), (AT):

Even more revealing than the @ sign is the HTML email attribute mailto:user@domain.co.uk. This enables website visitors to open their preferred email program with a simple click. Website operators are therefore advised to steer clear of classic patterns when providing their email address.

Business Email
Discover a new way to email
  • Write perfect emails with optional AI features
  • Includes domain, spam filter and email for­ward­ing
  • Best of all, it's ad-free

Classic rep­res­ent­a­tion of the email address without being protected

In order to be able to protect an email address as much as possible before it is auto­mat­ic­ally read out by email har­vesters, you have to envision how it is generally in­teg­rated into a web page. A simple, easily ac­cess­ible email address can be inserted into any HTML page using the following code example:

<p>If you have any questions or suggestions, please write an email to: 
<a href="mailto:user@domain.co.uk">user@domain.co.uk</a>.
</p>
html

From the user’s point of view this is an ideal rep­res­ent­a­tion of an online email address. In order to keep the display user-friendly, the most popular method for pro­tect­ing an email is to make it look un­re­cog­nis­able in the source text without changing how it looks in the browser. Al­tern­at­ively, it is possible to separate the email address from the actual website and forward it to the mailto link with a side-server redirect.

Tip

With email hosting from IONOS you com­mu­nic­ate in a pro­fes­sion­al way as well as securely and in­ex­pens­ively. Use per­son­al­ised email addresses with your own domain and have flexible access to your mails at any time. Also included is the archiving function, calendar and office solution and much more. You can also rely on the highest security standards in EU ISO-certified IONOS data centres.

Method 1: CAPTCHAs

CAPTCHAs offer the pos­sib­il­ity to protect email addresses on websites. In this process, encrypted email addresses are not displayed in plain text until users have proven that they’re human by passing a check. These checks ask the user to do a variety of tasks such as entering a com­bin­a­tion of letters or numbers, quick maths problems, or puzzles.

Tip

Google offers a free CAPTCHA service with reCAPTCHA.

CAPTCHAs offer a com­par­at­ively high level of pro­tec­tion against spam because email addresses are not displayed in the source code at all or only in encrypted form. CAPTCHAs can also fit well into your website’s design because there are so many different designs. The website’s user-friend­li­ness is affected due to the user having to put in extra effort to access the email address and also means that the ob­lig­a­tion to make important contact in­form­a­tion ac­cess­ible isn’t fulfilled.

Method 2: Replacing the email address

It is possible to remove the entire email address from the source code and replace it with either graphics or a redirect link to the mailto link.

Integrate email address as a graphic

If an email address is im­ple­men­ted as a graphic, it can still be read by the human eye, but texts written as graphics are hard for email har­vesters to recognise. Including cor­res­pond­ing contact in­form­a­tion as a graphic therefore protects email addresses on websites from spam. The HTML code would look like this:

<img src="Path/graphicfile.png" with="120" height="20" alt= If you have any questions or suggestions, please write an email to: user@domain.co.uk">
html

This email address is legible for most people. The text can neither be copied nor linked to a mailto link, which many users will find tedious to manually type in them­selves. Text in­form­a­tion in the form of a graphic is often not available for users with visual impair­ment. People with visual impair­ments can only read the address with the help of cor­res­pond­ing in­form­a­tion in the alt attribute. These can be read out with the help of screen readers, but the downside is that they are also available to spambots so this method alone is not re­com­men­ded as a pre­vent­at­ive measure against spam.

Note

There are oc­ca­sion­al spambots that can examine image elements for text elements using OCR (Optical Character Re­cog­ni­tion), but these are in the minority.

You can protect your email address on your website from har­vesters by sep­ar­at­ing it from the website. A script is generally used, which redirects users to the mailto link after the first click. This opens the user’s email program and displays the address. For spambots that scan the source code of a website, this link will look like a file link. This pro­tec­tion mechanism can, for example, be im­ple­men­ted as a link to a PHP file that contains the redirect:

<p>If you have any questions or suggestions, please write us an
<a href="redirect-mailto.php">email</a>.
</p>
html

The content of the redirect-mailto.php file is a script that redirects to the actual mailto link:

<?php
header("Location: mailto:user@domain.co.uk"); 
?>
html

The dis­ad­vant­age of this spam pre­ven­tion solution is that users need a handler for mailto: to get to the email address. In practice, this is usually an email program such as Outlook or Thun­der­bird. However, web mailers can also be entered as handlers in new browsers.

Method 3: Masking the email address

If you don’t want to com­pletely replace an email address with a graphic or a mailto link, there are al­tern­at­ive strategies to encrypt an email address on a website.

Masking by character encoding

Common character encoding, used when masking email addresses in the source code, is based on HTML entities or HEX code. This type of encoding is suitable because the re­spect­ive reference char­ac­ters are auto­mat­ic­ally trans­lated in the browser view.

If the char­ac­ters of the email address user@domain.co.uk are masked using HTML entities, they are first written in the al­tern­at­ive style:

@ = @ . = . (period)

This results in the following source code:

<p>If you have any questions or suggestions, please write an email to: 
<a href="mailto:user&commat;domain&period;com">user&commat;domain&period;com</a>
</p>
html

If you want to encrypt the whole email address , you can use HEX encoding. The Unicode character number is used and is listed in the following basic schema:

&#char­ac­ternum­ber;

Typically, the HEX number of the cor­res­pond­ing character is indicated by a small ‘x’. Thus the letter ‘m’ could be noted down as ‘m’ or decimal ‘m’. The email address user@domain.co.uk including the mailto link would look like this:

<p>If you have any questions or suggestions, please write an 
<a href="&#x6d;&#x61;&#x69;&#x6c;&#x74;&#x6f;&#x3a;&#x62;&#x65;&#x6e
;&#x75;&#x74;&#x7a;&#x65;&#x72;&#x40;&#x64;&#x6f;&#x6d;&#x61;&#x69;
&#x6e;&#x2e;&#x64;&#x65;">email</a>.
</p>
html
Tip

The cor­res­pond­ing reference char­ac­ters for trans­lat­ing an email address can be easily found from lists available online. A clear overview is provided on htm­lar­rows.com.

In principle, masking the email address can be done quickly and easily by character encoding. However, the pro­tec­tion offered is com­par­at­ively low since most spambots are now pro­grammed to easily decipher this simple form of en­cryp­tion.

Masking by adding char­ac­ters

Basically, it is possible to hide email addresses from spambots by inserting ad­di­tion­al char­ac­ters into them. Programs will then hopefully not see the address as a whole and therefore it won’t be able to be read out auto­mat­ic­ally. HTML comments, for example, provide a simple way to do this.

<!-- Comment -->
html

If comments like these are added into the email address, spambots (who scan the website) will stumble across the following code:

<p>If you have any questions or suggestions, please write an email to:
u<!-- Comment -->ser@domai<!-- comment -->n.co.uk.
</p>
html

While a human user will see the correct email address in the web browser, a spambot is expected to read out the blended text in the span element.

A dis­ad­vant­age of masking the address by adding extra char­ac­ters is that with this method the email address can’t be linked with an HTML email link. In this case, users must manually copy the address into their email program.

Method 4: En­crypt­ing the email address

A common method for email en­cryp­tion is ROT13, which can be im­ple­men­ted with just a few lines of JavaS­cript.

<script type="text/javascript">
function decode(a) {
return a.replace(/[a-zA-Z]/g, function(c){
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
})
}; 
function openMailer(element) {
var y = decode("znvygb:orahgmre@qbznva.qr");
element.setAttribute("href", y);
element.setAttribute("onclick", "");
element.firstChild.nodeValue = "Open email software";
};
</script>
<a id="email" href=" " onclick='openMailer(this);'>Email: please click</a>
html

In line 9 of the sample code, it shows the encrypted version of the email address user@domain.co.uk including the mailto text string (znvygb:orahgmre@qbznva.qr) as well as how it should be encrypted (in lines 2 to 7). The function in lines 8 to 13 opens the user’s preferred email program and writes the decrypted address into the recipient field.

The script is started by clicking on the link with the anchor text ‘Email: please click’ (lines 15 to 16). After being clicked on, this displays the text ‘Open email software’ (line 12).

Email Archiving
In­tel­li­gent mail archiving
  • Pro­fes­sion­al, automatic archiving
  • Securely stored in European data centres
  • Protect yourself against data loss
Go to Main Menu