Anti-Email Spam (email bot obsfucator)


Version: 1.3

This is a very simple plugin that attempts to hide email addresses from ‘bots (computer email harvesting programs). Why would you want to do this? Because these nasty little harvesting programs are used by equally nasty little spammers. They scour websites looking for email addresses, which are then added to their spam list.

All the plugin does is replace any email addresses in your posts and pages with an obfuscated version. Two types of obfuscation are available:

  • Entity encoding – this encodes the email address as HTML entities, making it invisible to most harvesting software
  • JavaScript encoding – the email is encoded as a short piece of inline JavaScript code

So which is best for you? Well, it depends. I’ve seen reports of smart spammers decoding entities and successfully extracting email addresses. However, this method will work on all browsers, regardless of JavaScript. On the other hand, spammers have not yet, as far as I’m aware, implemented JavaScript in their programs, so the JavaScript version should be ‘untouchable’. This is at the expense of emails being invisible to non-JavaScript enabled browsers.

The choice is yours.

After obsfucation the email address is wrapped in a mailto:, allowing viewers easy email access (while still stopping the ‘bots).


  • Download
  • Unzip
  • Change obfuscation, if necessary (see below)
  • Upload antiemailspam.php to /wp-content/plugins
  • Enable plugin from Plugin administration

You can find full details of installing a plugin on the plugin installation page.


Configuration is extremely simple. You can change the type of email obfuscation by editing the antiemailspam.php file and commenting/uncommenting the appropriate line:

//$anti_callback = "anti_callback_entity";
$anti_callback = "anti_callback_js";

JavaScript obfuscation is enabled by default. To swap to entity encoding the code should look like this:

$anti_callback = "anti_callback_entity";
//$anti_callback = "anti_callback_js";

NOTE: email addresses already inside a mailto: are ignored.

57 Responses to Anti-Email Spam (email bot obsfucator)

  1. Nice one!
    I’ve never heard ’bout your plugins before. It was a coincidence to get here through a link on some page.
    I just want to say: all of your plugins are very usefull!
    Keep on the good work … I’ve added you to

  2. Mmm iv tryed used this plugin for my custom form, iv added this line to script
    add_filter (‘the_content’, ‘anti_email_spam’);
    add_filter (‘c2c_get_custom’, ‘anti_email_spam’);
    but strange plugin not work for any, without my line and with my line
    my wp 2.2.3 and all emails posted without any link and mailto, only like text – example –
    plugin doe’t not work for text only? need added mailto?

  3. You can find full details of installing a plugin on the plugin installation page. [How to install a WordPress plugin] gets a 404.

  4. This plugin was breaking for me with wordpress 2.3.4 because it was running before the default wordpress auto-formatting filters. Then the wordpress filters would alter the javascript code making it generate javascript errors.

    Changing the anti_email_spam filter to run last fixed it for me

    Just add the 99 in the filter code to get it to run after all other filters.

    add_filter ('the_content', 'anti_email_spam',99);