Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop spammers from getting the email address from a mailto link? [duplicate]

Duplicate:

  • Best way to obfuscate an e-mail address on a website?
  • Effective method to hide email from spam bots
  • What are some ways to protect emails on websites from spambots?

What is the best way to prevent spammers from getting the email address from your mailto links? I'm under the impression that javascript could be a solution. I don't know if my current solution is fool proof, so that's why I'm asking.

Here's what I'm currently doing:

<script language="JavaScript"><!--
var name = "emailusername";
var domain = "yahoo.com";
var text = "[email protected]";
document.write('<a href=\"mailto:' + name + '@' + domain + '\">');
document.write(text + '</a>');
// --></script>

Is there is a better way? I don't like having to have this chunk of code everywhere I want to put a mailto link.

like image 691
Andrew Avatar asked Apr 20 '09 20:04

Andrew


2 Answers

  • Best way to obfuscate an e-mail address on a website?
  • Effective method to hide email from spam bots
  • What are some ways to protect emails on websites from spambots?
like image 184
vartec Avatar answered Oct 11 '22 15:10

vartec


Javascript helps, but this won't help much. The email address is still visible in the html source using this type of script.

The "best" options use client-side javascript to "build" the email address out of parts, so the entire email address is never visible in the HTML source in one piece. The browser puts it together for you on the client.

Example:

<script language="JavaScript"><!--
var name = "emailusername";
var domain = "yahoo.com";
document.write('<a href=\"mailto:' + name + '@' + domain + '\">');
document.write(name + '@' + domain + '</a>');
// --></script>
like image 27
Reed Copsey Avatar answered Oct 11 '22 13:10

Reed Copsey