chokk Posted December 29, 2010 Share Posted December 29, 2010 Hey all,I'm working on a project where an e-mail will be displayed and a mailto function attached to it.How do I prevent spambots getting hold of the mail?I thought of using JS, but JS enabled spambots can see right through it.Any ideas? Link to comment Share on other sites More sharing options...
Dilated Posted December 29, 2010 Share Posted December 29, 2010 Hey all,I'm working on a project where an e-mail will be displayed and a mailto function attached to it.How do I prevent spambots getting hold of the mail?I thought of using JS, but JS enabled spambots can see right through it.Any ideas?If you're talking about a mailto link, you can encode every character in the address as an entity. For example:mailto:foo@foo becomes: & #109;& #97;& #105;& #108;& #116;& #111;& #58;& #102;& #111;& #111;& #64;& #102;& #111;& #111; edit: Ugh, there's no real way to put entities here. Just ignore the spaces in between the ampersands and numbers.A simple php script could encode an address for you: $email = 'mailto:foo@foo';$encoded = '';for ($i = 0; $i < strlen($email); $i++) $encoded .= ''.ord($email[$i]).';'; Some bots might still be able to recognize that as a mailto link even if they're only looking at markup. In short, I don't think there is an exceptionally reliable way to obfuscate an email address. Dynamic insertion of the email address through JS would probably be effective, but you're right, if the bot is looking at the actual computed DOM, it wouldn't matter.But, maybe you wouldn't be inserting an @href. Maybe you could do something like: [a link].onclick = function() { window.open(String.fromCharCode(109)+String.fromCharCode(97)+etc); //make this extremely convoluted in case its reading raw scripts? }; But of course, as a side effect, the email link would only work with JS. Link to comment Share on other sites More sharing options...
Synook Posted December 30, 2010 Share Posted December 30, 2010 You could just use the server to send the mail instead... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.