WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to have the emails displayed on my pages/posts in such a way that they to not be able to be read/used by bots/spammers. So for instance I can use some plugin which replace "@" with "[at]" and so on, but in that case I am no longer able to automatically use mailto, like:

<a href="javascript:void(0)" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&amp;fs=1&amp;tf=1&amp;to=somemail@somedomain.com','Compose new message','width=640,height=480')" rel="noreferrer">somemail@somedomain.com</a>

Can you please suggest a plugin which can work for this case? (keep the email address as it's normally displayed but prevent bots to read it?)


share|improve this question

Spam prevention should be done on the email's servers side, by that I mean you should not disrupt your usability because of spam, instead you should use a proper spam block or filtering service on your email side. For example I have been using Postini for years and have pretty much no spam to contend with.

Another option to prevent really badly written bots is a simple encoded email using ascii or JavaScript, that way the bot reads the source and it is useless but the user is still presented with a valid clickable link,

for example:

    //becomes in ASCII

 <a href="mailto:&#116;&#101;&#115;&#116;&#064;&#101;&#120;&#097;&#109;

   //or a javascript example:

<SCRIPT LANGUAGE="javascript">

    var first = 'ma';
    var second = 'il';
    var third = 'to:';
    var address = 'test';
    var domain = 'example';
    var ext = 'com'; 
    document.write('<a href="');
    document.write('Click Here to Email Me!</a>');


You can find a generator here , http://www.ohlone.edu/org/webcenter/emailencoder.html or here http://www.wbwip.com/wbw/emailencoder.html and there are some javascript ones out there as well like this jQuery one http://plugins.jquery.com/plugin-tags/email-encode

share|improve this answer
There's also WP's built in function antispambot(). E.g.; <?php echo antispambot(get_the_author_email()); ?> More on this: codex.wordpress.org/Protection_From_Harvesters – goto10 Oct 11 '11 at 16:45
wow did not know that! – Wyck Oct 11 '11 at 19:05

There's a core function for that: wp_mail( $to, $subject, $message, $headers, $attachment );

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.