WP plugin: Email Immunizer

posted on August 23, 2005

Inspired by a support forum thread, I wrote Email Immunizer, a little WordPress plugin which provides protection against email harvesters by taking email addresses and mailto links on your blog and converting their text to numeric character references.

To install, here’s those very hard to follow instructions: download the zip file and extract email-immunizer.php from it, upload this to your wp-content/plugins directory, then activate Email Immunizer under Plugins in WordPress.

From then on just write your email addresses as normal. The plugin works straight off seeking out and displaying any and all addresses it finds throughout your blog, morphing them into HTML-ized equivalents by making use of the internal WordPress function antispambot() for the alphanumeric to character reference conversion. There’s lots of things hiding in this blogging tool.

(Plugin note: Another of those “didn’t know about that one” episodes of mine. Scott Reilly (Coffee2Code) released a very similar plugin some months back: Obfuscate Email. Thanks to Bryan for helping confirm I’m an unoriginal hack. Hey, at least now you have options!)

Email Immunizer currently filters on the following blog components (associated template tags in brackets):

  • author email (the_author_email())
  • post/Page content (the_content())
  • excerpt (the_excerpt())
  • comment author email (comment_author_email())
  • comment text (comment_text())
  • comment excerpt (comment_excerpt())
  • RSS-formatted content, excerpt & comment text (the_content_rss(), the_excerpt_rss(), comment_text_rss())

If you’ve applied more manual methods for converting email addresses on your blog previously, Email Immunizer will in most cases leave them be. So you shouldn’t need to edit old posts and whatnot, reconverting obfuscated addresses to standard ones. Thought it important to note that.

Author: Kaf Oseo
Categories: WordPress
Comments: (29) · Leave a comment · Comments RSS2 · Trackback URL

Bryan Villarin
Comment » August 24, 2005 @ 2:10 am

Is this better than Obfuscate Email from Coffee2Code?

Kaf
Comment » August 24, 2005 @ 9:35 am

Well there you go. I was unaware of Scott’s plugin.

Email Immunizer handles things a tiny bit differently (though admittedly that doesn’t count for much if comparing the two). And it hits more WordPress elements automatically, such as post and comment author, and the rss-formatted output (Obfuscate Email could be updated to work on these, though). In the end they accomplish pretty much the same thing, so I’ll let y’all decide what’s “better.”

Bryan Villarin
Comment » August 24, 2005 @ 2:02 pm

I guess it’s hard to find because of the name “Obfuscate”. That’s a HUGE word (at least to me). Oh well! :)

Craig
Comment » August 25, 2005 @ 4:34 am

Sweeeeet! Thanks, Kaf!

Nitallica
Comment » September 5, 2005 @ 11:26 pm

“Thanks to Bryan for helping confirm I’m an unoriginal hack.”

Hey, if it’s any consolation, I think you’re brilliant! ;)

I came by here looking for one particular plugin, and found 3 more that I liked. I’ve always appreciated the help you’ve given me and the other visitors at the WP support forums.

Thanks for all of your hard work! :)

Mathias
Comment » September 24, 2005 @ 7:28 am

Kaf, feel free to use my obfuscate_email() PHP function in your plugin for even more obfuscation goodness.

Suresh Jain
Comment » January 23, 2006 @ 11:46 am

Great

Marcos
Comment » July 2, 2006 @ 10:33 am

I love your plugin. I installed it and all the links with my mail were transformed automatically. I’d rather discovered it months ago… Thank you a lot :)

Blowfly
Comment » August 26, 2006 @ 9:53 pm

HOT DOG! I just installed this on a bunch of my sites. Thanks!

Ovidiu C. Balan
Comment » September 15, 2006 @ 5:26 am

this is just a comment email test
nice@email.com

Let’s see!

thayer
Comment » October 31, 2006 @ 4:30 pm

This is a great plugin and thanks for releasing it under GPL. I’m trying to make it so that the plugin leaves the “mailto:” part of the affected href intact, but I’m having a hard time figuring out the regular expressions used in the script. I would like to use Email Immunizer along with Michael Woehrer’s Link Indication plugin, allowing me to add envelope icons next to all text-based email links, but EI is scrambling the mailto: reference that Link Indication requires for CSS classification. Can anybody help me out on this one?

Kaf
Comment » October 31, 2006 @ 4:53 pm

thayer, I’ve replied to your query by email…

Actually, turns out I didn’t. Getting a send failure on address you left. Contact me by email and I’ll resend the note.

Roy
Comment » November 7, 2006 @ 10:21 pm

Hi. Great plug-in. But is there a way to get it to work on the Side Bar? I want to put my email address there, and Email Immunizer isn’t scrambling it. :(

Kaf
Comment » November 7, 2006 @ 11:12 pm

Roy, when inserting an email address into a WordPress theme template (raw, as they say), do it this way:

<?php echo email_immunizer('me@mydomain.com'); ?>

Roy
Comment » November 8, 2006 @ 10:47 pm

Yes! I got it now. Thanks!

lewism
Comment » December 8, 2006 @ 6:10 am

Thanks for this plugin, it’s simple to use and really useful.

Herrin
Comment » December 27, 2006 @ 12:37 am

Love the plugin and really good knowing that the email addresses of customers are protected too. Maybe a little button that I can advertise the fact with. Protected by Email Immunizer button perhaps. I also use SK2 and Bad Behaviour but yours protects the visitors which is probably more important to the users and visitors of these websites we all have. Cheers any way and have a great new year.

X-Ride
Comment » March 21, 2007 @ 12:09 pm

Thank you, let’s hope it reduces the amount of spam emails that we get received. Thanks again! :)

Steve
Comment » June 25, 2007 @ 7:12 am

This is great, thanks. I have a request, though. Currently, it doesn’t seem to be working within widgets. I am using my email address within ExecPHP widget and it is not being immunized, but when I use it in within a normal WP Page, it is.

Is this something you can add, please?

jack
Comment » January 3, 2008 @ 1:52 pm

Very nice plugin… but how can I check if it is working?
I’m using my email address once in a page and several times in my templates (header and such), using this code you gave above:

< ?php echo email_immunizer('me@mydomain.com'); ?>

When I check my page the addresses look like if nothing happened to them…

Shyam Gupta
Comment » August 4, 2008 @ 4:41 am

This type of obfuscation doesn’t works if it is a mailto: link. I tested and could harvest the e-mail addresses. Harvesting failed (in my test) only when the e-mail address was text only i.e. it was NOT a mailto link.

 

* Required field (e-mail is not published). Breaks and paragraphs are automatic. HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>