1

I am displaying the email addresses stored in the database on a page using PHP. The email address on a page is displayed as below:

Email: test@example.com

Now the email address shown on a page should use JS spam protection to hide it from spam bots.

snew
  • 101
  • 2
  • 10
  • 1
    I searched the google before posting this question here. I didn't get the solution which meets my requirements. So posted here. Stackoverflow is very helpful in finding answers that meets your requirements :) – snew Dec 23 '09 at 07:58

7 Answers7

1

Try an email encoder, or implement one in your script.

Traveling Tech Guy
  • 27,194
  • 23
  • 111
  • 159
1

you can try to use image (with php-gd lib) write on a image then show this. (like facebook)

Murat Kucukosman
  • 634
  • 5
  • 11
0

Here are some good resources to look at:

Hiding Email from Spam Bots
Displaying Emails for Users, But not Spambots.
Making Email Addresses Safe from Bots

You could probably find more using a Google Search of StackOverflow.com

Oh, and there are ones asking if you 'should' do it:

Does Hiding Emails really make it harder?
Do You Hide Email from Spam Bots on Websites

Community
  • 1
  • 1
Tyler Carter
  • 60,743
  • 20
  • 130
  • 150
0

I'd argue that you're better off not bothering; client-side spam filters are pretty good these days, and by jumping through hoops youjust make thing harder for humans.

That said, the best way is to convert it to whatever kind of format you want, whether it's an image or a simple string substitution:

joe@domain.com -> joeATdomainDOTcom

and then write the address out marked up with some kind of class identifier:

<a href="mailto:joeATdomainDOTcom" class="Email">
  <!-- image or link text here -->
</a>

Then use Javascript to decode all the email links and re-write the href attribute to the real address. Most spiders crawling for email addresses won't execute Javascript, so the encoded semi-useless address is all they'll see.

Users with JS enabled will get more or less expected functionality (clickable mailto links) while users without JS will at least get human-readable addresses.

The worst thing you can do is write the unencoded addresses out, and trust some Javascript to hide them.

user229044
  • 232,980
  • 40
  • 330
  • 338
0

PHPEnkoder (a port of Hivelogic's The Enkoder)

"Enkoder, which works by randomly encoding a piece of text and sending to the browser self-evaluating Javascript that will generate the original text. This works in two ways: first, a bot must first have a fairly complete Javascript implementation; second, the decoding process can be made arbitrarily computationally intensive."

It's BSD-licensed.

Community
  • 1
  • 1
micahwittman
  • 12,356
  • 2
  • 32
  • 37
0

Try http://recaptcha.net/learnmore.html It can protect email addresses with a captcha..never tried it though, but i uses reCaptcha for a login form and it was easy to work with.

Quamis
  • 10,924
  • 12
  • 50
  • 66
0

Displaying them as pictures is one option. Also requiring the user to pass CAPTCHA test before seeing the e-mail address works too. Combine those two and spam bots will likely never get the e-mail addresses.

TheMagician
  • 1,846
  • 7
  • 20
  • 26