Email Address on Your Site, SPAM Protection, Obfuscating

The email address obfuscater on this page allows you to show your email to visitors of your site while hiding or obfuscating it from spammers, by scrambling or enciphering it. It transforms your email in a code you can put on your site. Visitors of your site, with Java activated, can read the email they can click on it to send you an email but it will be protected from spambots or email harvesters.

Go down to: Obfuscate your email address icon in-page link

Update (): adapted to php7.4.

'Bugfix': the bug I thought was in this script was actually on my site [2024-04-22].
The script is working fine.

First published:
Last update:

Placing emails on your site

For most site owners, placing an email on the site so visitors can get in contact, is very important. Preferably visitors only need to click on the email address, write a message and sent it.

Unfortunately, putting your email on your site or any other place on the Internet, has become a problem. With the growing use of the Internet and emails, the problem of spam is also getting bigger and bigger. One of the things spammers do is email harvesting. That is, scanning the Internet to find emails to which they can send their spam. For this reason, it is not a good idea to put an email on you site just like that, without obfuscating it from spammers. If you do, it won't take long before you start receiving spam, and it won't take long before you receive so many spam mails, it becomes difficult to find emails that interest you between them. That is why you need to protect emails on your site by hiding them from spammers.

Go down to: Obfuscate your email address icon in-page link

Four classic ways to hide emails

Basically there are four ways to hide emails from harvesting bots.

This multi-key email address obfuscater

The email address obfuscater on this page should provide better protection because it uses different keys for standard elements and non-standard elements of the email address. Moreover, it produces a Java script which needs to be run in the visitors browser to decode the email. It seems that, at least for the moment, spambots can not run Java scripts.

Using the same key for everything makes it too easy to find the email address. As said above, it is not very difficult to discover a key based on a standard. Standard elements like [mailto:] or the domain name can give away the key. Comparing the encoded email address with standard elements like this, makes it possible to derive the key and discover the enciphered email. Using a separate key for different parts of the email address makes it much more difficult to find the hidden email address. That is the principle behind the email address obfuscater on this page. Care was also taken that no part of the encoded email is recognisable anywhere in the produced Java script.

Go down to: Encrypt your email address icon in-page link

Privacy

As can be expected from this page, I don't like spamming nor other invasion of privacy. Therefore I will not collect, much less pass to others or sell the email, entered in the fields, to be encoded. The code is generated automatically and, as far as I can control it, non of the entered or generated information will be stored or provided to others.

Free

Some things still are for free. I use much of the free stuff available on the Internet, some of it is really good. That is one of the reasons I chose to place this email address obfuscater on my site and allow visitors to use it for free, to contribute, to give something back.

Obfuscate your email address

To have your email address enciphered or obfuscated, type it in the given spaces, click [Generate] and the JavaScript code will generated. Select all the Java code from the box. Copy and past it to the page where you want the email to appear, at the place where you want it to appear. For your visitors it will work as a normal [mailto] link. They can read it, click on it so their email program opens with the address in the right place, they can copy and past the email address. Email harvest bots will neither recognise it nor will they be able to decipher it.

This email address obfuscater will not be bot-proof forever but it is better than what I have seen. Until now (last update) it seems to work fine enough. Emails on this site don't seem to be harvested by spambots, only by human email harvesters. Automatic harvesting and spamming typically shows an exponential increase of spam which hasn't occurred and content of received spam is linked to the content of the site. Hopefully this email address obfuscater is going to work fine enough for quite a while longer.

Try it and if you like it, I would appreciate some feedback like an email a message on Signal or my message board icon exit-page link, informing how well it worked. If you don't like it or found a problem, feedback will be greatly appreciated as well.

'Bugfix': the bug I thought was in this script was actually on my site [2024-04-22].
The script is working fine.

Generate code of email address obfuscator

@

Please, leave intact, in the Java code, the note with author, link and copyright.

This is the email address obfuscated with the JavaScrip above:

How to put the JavaScript on your web page

To have the obfuscated email show on your web page, readable and clickable, copy the generated code from the box. Put it in your html file between script tags <script> </script> or without these tags in a file with the extension .js for JavaScript. Something like obfuscated-mail.js

Place an html element like a paragraph or a div with id="encrptpost", there where you want the obfuscated email to appear. With the present code only one email per page possible and only this ID id="encrptpost" will work. The JavaScript will replace the content of this element, if any, with the obfuscated email.

You can write something like a placeholder or warning in the element. Two examples:

<div id="encrptpost">Email should be here.</div>

or

<p id="encrptpost">Something went wrong. The contact email should be here.</p>

After this element, call the JavaScript file into the html file as shown below:

<script src="obfuscated-mail.js"></script>

In case the file is not in the same folder as the one where it is used, the path needs to be informed. Something similar to the following.

<script src="../java/obfuscated-mail.js"></script>

If you really need more than one address on one page this is possible by, for each, using a different HTML ID, a different JavaScript file and making the appropriate changes in the html code and JavaScript.

For each email-address change the ID from encrptpost to thenameyouwant in the respective html tag, like from

<div id="encrptpost">Email should be here.</div>

to

<div id="thenameyouwant">Email should be here.</div>

Change the name of the JavaScript file and in the html file, the JavaScript for calling this file apropriately. Like from

<script src="../java/obfuscated-mail.js"></script>

to something like

<script src="../java/obfuscated-mail-two.js"></script>

In the here generated JavaScript, find the following line

document.getElementById('encrptpost').innerHTML = mailToShow;

and change it to

document.getElementById('thenameyouwant').innerHTML = mailToShow;

Following these steps should do the trick.

First published:
Last update:
HTML5