Having a clickable link with your email address on your website is a very practical thing and should not be omitted. But there are robots searching the internet for this email addresses and they will also find your address. The most spam filters are very good but there are always some spam mails that come through and this is very annoying.
Solution?
I really don’t think it is a solution anymore but on many websites are email addresses in the form mail[AT]example.com
. Maybe some really dumb robots don’t find these but if I would write a bot I would include email addresses like this in my search algorithm.
Better Solution
The better solution exploits the fact that these bots usually don’t execute javascript code. So using ajax to get the address from the server and populating the email link with it should stop many bots from finding the email address.
This is a very simple example that does not work on very old versions of the Internet Explorer and without any error handling. But it does the job.
The HTML:
But again, if I would write an email address search robot I would try to find ajax requests and also look at the destinations of these.
Solution
To prevent this it would be possible to integrate some logic on the server that checks if the request for the email address really comes from the website. The second improvement would be to obfuscate the address email.php
.
This could look like this:
|
|
No JS Workaround
If the user visiting the website has javascript deactivated he doesn’t see an email address, but for example in Austria it is mandatory to have an email address on the website. This can be done by inserting an image with the email address and hiding it when the email address is loaded with javascript.
By putting the image in the link it is automatically removed when it is overwritten by e.innerText = this.responseText
;