0

Recently, a friend of mine posted their email address using the mailto tag and has received a lot of spam bots because of this.

I'm just wondering whether or not it is possible to detect whether a person is using a "proper" browser to access the webpage, and, if they are, display the email address, if they are not, then do not display their email address?

I know you can get what someones email address is using HTTP_USER_AGENT but I don't really want to have to compile an array of the capable browsers and just wondered whether or not there is a pre-defined function in PHP.

Any help would be greatly appreciated.

P.S. I'm not asking for specific code, references will do.

Phorce
  • 2,632
  • 13
  • 43
  • 76

2 Answers2

2

no, parse the array or leave it

E: Regarding your spam bots, assembly the emailadresse for the mailto with javascript, works fine for me and i never got spammed

Soundz
  • 1,308
  • 10
  • 17
  • Thanks for the reply. Could I do something like this: http://stackoverflow.com/questions/11595160/javascript-mailto-function-loading-issue? – Phorce Feb 26 '13 at 00:35
  • could be even simpler var a = 'firstpart_of_mail'; var b = 'second_part_of_mail'; document.getElementById('mail-link').innertext = 'mailto:'+a+'@'+b; (without warranty ;)) – Soundz Feb 26 '13 at 00:40
1

While you could filter browsers by UserAgent from listings such as user-agents.org or use the built in detection through the get-browser method, you're still likely to get your address picked up by spiders if it's displayed in the raw html, due to UserAgent Spoofing. You are better off using javascript to display a mailto link, using window.open("mailto:example@example.com") with whatever other parameters you want to have included, and triggering using <a onclick="jsfunction" href="javascript:void(0);">.

EDIT: Or dynamically forming the link using a script on page load.

  • Note that there are already some bots that are smart enough to run javascripts. Its like warfare. You come up with a good idea to block, but after a while, they come up with a way around it. :( – iWantSimpleLife Feb 26 '13 at 01:01
  • True, true. A dynamically generated link is probably the best bet then. As it affords the simplicity of a mailto, without the ease of running a script. Though all of the above approaches fail if the bot uses a simulated browser environment like PhantomJS. – Andrew FigPope Feb 26 '13 at 01:05