Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show email addresses on the website to avoid spams?

I show email on my website as following

 <a href="mailto:[email protected]">Email</a> 

But I read the following while analysing my website using woorank.com, what should I do to avoid this?

Malicious bots scrape the web in search of email addresses and plain text email addresses are more likely to be spammed.

like image 400
Jack Avatar asked Apr 11 '14 02:04

Jack


People also ask

Should I display my email address on my website?

As a website operator you're advised to include your email address on your website so that you can easily be contacted by visitors. The problem with including your e-mail address is that you could find yourself inundated with spam.

How can email spam be prevented?

Download spam filtering tools and anti-virus software Spam filtering tools and anti-virus software can help to scan the emails that you received for malware. If the emails that you received contain malware, the malicious content would be quarantined and you would be prevented from opening it.


2 Answers

In the past I have seen this done with javascript. Basically you assign the email address to javascript variables and change the contents of an element using these. You can also provide a fallback for users with javascript disabled which points them in the direction of a form if you need to. Here's an example

var user = 'foo',     domain = 'bar.com',     element = document.getElementById('email');      element.innerHTML = user + '@' + domain;     //OR     //'<a href="mailto:' + user + '@' + domain + '">Email</a>'   

This way bots never see the email address as they do not load javascript.

like image 136
JazzyP Avatar answered Oct 03 '22 22:10

JazzyP


Well, you can figure out a different way every day. Here's one using jQuery.

<a class="mail" href="mailto:[email protected]">e-mail</a> 

Then handle the click with jQuery.

$('a.mail').on('click', function(){     var href = $(this).attr('href');     $(this).attr('href', href.replace('badmail.', '')); }); 

The reason I like this is that I can let the spammers spam the dummy mail domain thinking they got yet another e-mail harvested. If I was maintaining my own spam filter, I could collect samples to my bad bucket.

Also, this approach allows you to render the page quite clean with dynamic data and simply have the javascript snippet only once on the whole site to handle the real user clicks.

Works also on mobiles.

like image 44
Jani Hyytiäinen Avatar answered Oct 03 '22 23:10

Jani Hyytiäinen