Click here to Skip to main content
15,917,455 members
Articles / Web Development / ASP.NET

Fooling those e-mail harvesting spam bots

Rate me:
Please Sign up or sign in to vote.
2.38/5 (10 votes)
3 Feb 2007CPOL2 min read 32K   15   9
How to expose e-mail addresses safely on web sites without having to resort to e-mail forms.

Introduction

My client in my latest project presented an odd request: he wanted his e-mail addresses written in clear text in his web site's contact information page. I tried to explain to him that he would be better off using an e-mail form and a captcha control to avoid all the spam, but even when he understood the ramifications of exposing his e-mail addresses, he insisted that his potential clients weren't likely to fill in any e-mail forms. They might have become comfortable with e-mail over the years he said, but adding a simple e-mail form was apparently pushing the limit.

Background

As the customer is (supposedly) always right, I started shopping around for answers and came across this CodeProject article on encoding of e-mail addresses. The idea there is that the bots aren't likely to recognize the e-mail address pattern hidden in the encoding, and certainly not sophisticated enough to crack the code.

I was going to try that out when it struck me that the solution could be a lot simpler: How about just using an image button that looks like an e-mail address?

I know, it is so simple that it is almost not worth an article. Or, maybe that is exactly why it is?

Using the Code

I shall not elaborate too much on the code, as I am sure most of you already understand what it is I am driving at. However, for those who need a little more help, here is what you can do:

  1. Create a user control with a single image button.
  2. Take a screenshot of the e-mail address that you want to display, and reference it from the image button. To be on the safe side, call the image and the button control something unrelated to e-mails.
  3. In the OnClick event in the code-behind, make a reponse.redirect("mailto:someone@somewhere.com").
  4. If you want to be really fancy, you could add a onmouseover/onmouseout image swap to make it look exactly like an e-mail link.

Points of Interest

One obvious drawback is, of course, that the next time you change the styles in your site, all your e-mail links will be out of touch.

Hence, a custom control that would expose a simple CSS class and e-mail name property could indeed draw the control image(s) on the fly.

Ideally, such a control would base the text drawing on the <a> tag specifications on the page, or in its associated CSS files if no other CSS class is specified, and draw the button images accordingly.

I admit (after Googling it) that this is not an entirely original idea (see here and here, for example). Still, I would think a control like this would be useful for most developers to have in their toolboxes. I for one could certainly imagine simply writing:

ASP.NET
<cc1:EmailImage id="EmailImage1" runat="server" 
       cssclass="emailname" emailName="test@test.com"></cc1:EmailImage> 

the next time the clients want their e-mail addresses exposed.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralBots Pin
GHoffer5-Feb-07 10:51
GHoffer5-Feb-07 10:51 
What makes you think that the bots would not pick up on the 'emailName="test@test.com"' in the HTML and peel out the test@test.com address?

Gary G

AnswerRe: Bots Pin
RayBez5-Feb-07 21:06
RayBez5-Feb-07 21:06 
AnswerRe: Bots Pin
jokva6-Feb-07 5:50
jokva6-Feb-07 5:50 
GeneralRe: Bots Pin
Souls_End6-Feb-07 10:23
Souls_End6-Feb-07 10:23 
GeneralRe: Bots Pin
jokva6-Feb-07 18:00
jokva6-Feb-07 18:00 
GeneralRe: Bots - Additional Pin
jokva6-Feb-07 18:49
jokva6-Feb-07 18:49 
GeneralRe: Bots - Additional Pin
Souls_End6-Feb-07 21:41
Souls_End6-Feb-07 21:41 
GeneralRe: Bots - Additional Pin
jokva7-Feb-07 3:34
jokva7-Feb-07 3:34 
GeneralRe: Bots - Additional Pin
Souls_End7-Feb-07 16:58
Souls_End7-Feb-07 16:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.