Email Protect WordPress Plugin
- Automatically protect email addresses from spam harvesters in posts, pages, and comments
- Obfuscate email addresses using text (myemail [at] example [dot] com) or images
- Control email text replacement for the “@” sign and final period in emails
- Control font, font color, background color, and border color of obfuscated email images
- Convert any email address in your template into obfuscated text or images by inserting a simple function call into your pages
The Email Protect WordPress plugin protects email addresses from being harvested from spam robots by converting them into forms that aren’t recognized. With Email Protect you can choose to obfuscate your email addresses in text form or image form.
Want to see some examples?
Text Obfuscation:
myemail [at] example [dot] com
Image Obfuscation:

Email Protect allows you to chose the text that replaces the “@” symbol and the final period in the email addresses. If you chose image replacement you can chose the font, font color, background color, and border color of the replacement image. Email addresses in comments are always converted using text obfuscation.
You can also replace images manually in your templates by inserting a simple PHP function (see “Usage”, below).
| 1. | Download “emailprotect.zip” and unzip it. |
|---|---|
| 2. | Upload the entire plugin folder to wp-content/plugins/ and activate from the Plugin administrative menu. |
| 3. | Before the plugin will work you must enter your settings under “Email Protect” in the “Settings” menu (also called “Options” in pre-2.5 WordPress versions) |
Email Protect is fully compatible with the WordPress 2.5 automatic upgrade feature. If you chose not to use the automatic upgrade feature, disable the Email Protect plugin, delete your existing folder, upload your newly downloaded Email Protect folder, and reactivate the plugin.
Email addresses are automatically obfuscated in posts, pages, and comments. You can chose the obfuscation method (text or image) under the “Settings” menu. Email addresses in comments are always obfuscated using the text method.
To obfuscate an email address directly in a template file, enter a PHP code that mimicks the following style:
<?php if(function_exists('ep_email_protect')){ ep_email_protect($email, $type); } ?>
The $email variable holds your email address and the $type is an optional variable that can either be “text” or “image” depending on the type of obfuscation you want. If you don’t specify a type the default setting in the options menu is used. For example, if your email address is myemail@example.com and you want it converted into an image, you would enter the following into your theme’s template file:
<?php if(function_exists('ep_email_protect')){ ep_email_protect('myemail@example.com', 'image'); } ?>
If you wanted text obfuscation, simply change “image” to “text.” It is important to remember the single quotes around both the email address and the type in the above function. The function above is designed so that if you deactivate the plugin it will not break your theme.

| Email Replacement Method | Choosing “text” or “image” sets the default replacement obfuscation method for email addresses. This does not affect comments as they are always obfuscated using the text-based method. Also, if the template function is used it uses this method by default unless the user specifies otherwise |
|---|---|
| Replace “@” with: | The text entered here replaces the “@” symbol in text obfuscated email addresses. I recommend [at] or something to allow a human to recognize that it is an email address. |
| Replace the final period with: | This text replaces the last period to appear in the email address in text obfuscated email addresses. For example, if your email address is example@my.site.com, only the period between “site” and “com” will be changed. I recommend using [dot] or something similar. |
| Background, Font, and Border Colors | The entered text here must be the 3 or 6 digit hex color code for your desired color. There are many hex color converters available for free. Each box changes the corresponding color in the image obfuscated email address. |
| Email Font | You can chose from one of nine pre-defined fonts for your image obfuscated email address. |
Coming soon (as soon as someone asks a question!)
- Version 1.0.1: minor bug fixes
- Version 1.0: primary release on June 8, 2008
Copyright © 2008 by John Kolbert (aka Simply-Basic.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


I have a question/bug comment.
My image does not want to appear where I type my email address, rather it comes out dead right of where ever I type it on the page.
This is using the automatic settings on using the feature on a Page.
Thanks for the script. The image feature is maybe the best way to hide our emails.
Just a side note also..
If you downloaded this Plug-In you need to get the latest at the the WP Plugin Site where John posted the lastest version 1.0.1
http://wordpress.org/extend/plugins/email-protect/
Carlos:
Thanks for pointing out that I forgot to update this page with the latest version! I’ve got that fixed. Also, you can try surrounding your image with some CSS to locate it where you want.
On line 221 of the plugin it says:
$content = str_replace($emails[0][$i], "<img src="{$plugin_path}Try adding a style attribute in to the image such as:
$content = str_replace($emails[0][$i], "<img style="float: left;" src="{$plugin_path}Don’t forget to surround the quotes with forward slashes like I did, otherwise you’re plugin will give you a bunch of errors. If this fixes you’re problem I’ll consider adding an option where you can enter style info for the image directly into the options page. Let me know you’re results.
This is how I ended up editing the Line 221:
$content = str_replace($emails[0][$i], "<img style="float: left; margin: -17px 0 8px 120px; padding: 0 0 0 0; " src="{$plugin_path}image.php?id={$encrypt_email}&font={$options['se_font']}&bg={$options['se_bgcolor']}&ft={$options['se_ftcolor']}&bd={$options['se_bdcolor']}" /> </style>", $content);Notice that I added the
"and not just the"I didn’t know much of the Syntax definitions for PHP but the"alone without thegave me Script-wide(Global) error.Again, this is so the auto-image settings display the image to the right with some room, in my case, for my name. i.e.
My Name myname@email.comformat.I don’t know how it will work for the tag insert method where you manually put the insert the code.. ie.
<?php if(function_exists('ep_email_protect')){ ep_email_protect('myemail@example.com', 'image'); } ?>But I imagine they use the same line of code.
Hope that helps in your future development.. I really enjoy the plugin..
Thanks
Carlos
Ugh..
Wordpress doesn’t play nice..
Where I wrote
“Notice that I added the ” and not just the ” I didn’t know”
I mean I used \” = backslash and quotes, not just “. The backslash will save you from Syntax errors.
P.S. I see that you might have included the backslash to your comment John, but Wordpress might of taken it out :x
Carlos:
Ah, yes. The backslash is called escaping and it’s needed for nested quotes in PHP. And you’re right, WordPress is stripping them out in the comments. I need to install a plugin (or make one) that handles that better.
I’m glad you got it to work. Thanks for taking the time to report back. I’ll create a box in the options page where you can insert style information for the image in the next release. That way people won’t have to manually edit the php file.
Hello,
I just wanted to note to other users of this lovely plugin that if you want to display user’s emails as images in the author.php templates, you’d use the following line of code:
<pre lang=”php”
user_email, ‘image’); } ?>
er..let me retype that…
user_email, ‘image’); } ?>
Very useful little plugin, however it would be perfect if the text replacement replaced all the dots in an email with eg [dot] for uk email addresses which are domain.co.uk (ie domain dot co dot uk).
Any reasons for not implementing this?
With this plugin set on site doesn’t validate (http://validator.w3.org/)
@Przemek: What invalidation message does it give you?
Hi John, your plugin works very well in post content, can it be extended to work for custom fields too? Right now I use this code to display the custom field which contains the email address For this I use http://coffee2code.com/wp-plugins/get-custom-field-values/
I use custom fields to display post submitters email on a dog adoptions website.www.adoptiicaini.ro