Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?)

Thanks.

share|improve this question

2 Answers 2

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:

    **test@example.com**
    //becomes in ASCII

 <a href="mailto:&#116;&#101;&#115;&#116;&#064;&#101;&#120;&#097;&#109;
 &#112;&#108;&#101;&#046;&#099;&#111;&#109&#116;&#101;&#115;&#116;&#064;&#101;
 &#120;&#097;&#109;&#112;&#108;&#101;&#046;&#099;&#111;&#109;"></a>

   //
   //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(first+second+third);
    document.write(address);
    document.write('@');
    document.write(domain);
    document.write('.');
    document.write(ext);  
    document.write('">'); 
    document.write('Click Here to Email Me!</a>');

</script>

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
1  
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

 
discard

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.