Last Updated: February 25, 2016
·
736
· dpaluy

Protect Email From Spam Bots

TL;DR

Spam bots are getting a lot smarter at harvesting email addresses from web pages. Use encode option while using <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-mail_to" target="blank">mailto</a>

Ways to protect your email: me@domain.com

  • Weak solution - substitute characters: meatdomaindotcom
  • Weak solution - HEX encoding: %6d%65@%64%6f%6d%61%69%6e.%63%6f%6d
  • Better solution - Javascript encoding:
mail_to "me@domain.com", "Contact us", encode: "javascript"

Check more details <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-mail_to" target="_blank">here</a>.

Another way to encode your mail_to with JavaScript

<a href="http://www.jottings.com/obfuscator.htm" target="_blank">Email obfuscator script 2.1 by Tim Williams</a>

Important! You can't protect your email 100%

If the bot evaluates JavaScript before harvesting email addresses, you can't resist it.

For example, it can be done using <a href="http://phantomjs.org/" target='_blank'>PhantomJS</a>