PDA

View Full Version : Preventing spam email from my web site


Finland Blue
07-26-2006, 05:23 AM
I want to have my email address on my web site as a link - but I don't want to receive spam mails because of it.

Can anyone advise ways I can acheive this?

Thanks.

dreamlynx
07-26-2006, 05:43 AM
If your going to have a email on your website that the public can see then you are going to get spamed. the best way would be to have a contact form with the email not in the source code. Use the php one that is available on this site and then only the sendmail form would be available in the source.

That's your best bet.

Creative Insanity
07-26-2006, 10:21 AM
I agree with him up there..
BTW DL.. get off me man you are heavy LOL

domedia
07-26-2006, 12:54 PM
With the condition of having the email as a link on your webpage, your best option is more likely to be to have javascript write it out for you. The browser will be able to display your link and make it function like a normal email link, while spam bots that normally don't read javascript donesn't see it.

Here an example of this technique:
http://javascript.internet.com/miscellaneous/no-spam-e-mail.html

ranjan
07-26-2006, 09:29 PM
<!-- // Spam Free Email Links - by Ranjan Datta
function explodeArray(el,dl){
a=new Array(1); var i=0; var s=new String(el); s=s.substring(7,s.length);
while (s.indexOf(dl)>0){a[i]=s.substr(0,s.indexOf(dl)); s=s.substr(s.indexOf(dl)+1,s.length-s.indexOf(dl)+1); i=i+1}
a[i]=s; return a;
}
var f=new RegExp(/^mailto:([a-zA-Z0-9_.-])+_at_NOSPAM_(([a-zA-Z0-9-])+_dot_)+([a-zA-Z0-9]{2,4})+$/);
function obEmail() {
if(document.getElementsByTagName) { x=document.getElementsByTagName('a');
for (var i = 0; i < x.length; i++) {if (f.test(x[i])) {var y=explodeArray(x[i],'_'); y=('mai' + 'lto:' + y[0] + '@' + y[3] + '.' + y[5]); x[i].setAttribute('href',y);}}
}
}
window.onload=obEmail;
//-->


To use it


Email Me (mailto:abc_at_NOSPAM_xyz_dot_com)


Why use this code?

Because it degrades gracefully. If javascript is turned off the link still works and gives abc_at_NOSPAM_xyz_dot_com which a human being is capable enough to convert to abc@xyz.com

d a v e
07-27-2006, 05:54 AM
i've bene using thgis successfully for the last year or more
http://www.pinnacledisplays.com/unicode-converter.htm

domedia
07-27-2006, 01:22 PM
Hey Ranjan, can you elaborate just a tad more on that post so we can turn it into a article on the homepage? :)

ranjan
07-27-2006, 05:59 PM
In plain and simple HTML if you were to create a mailto link for an email address say "abc@xyz.com", this is how you would do it:

Email Me (mailto:abc@xyz.com)

The problem with such a link is that email harvesting robots look for the "<a>" tags that contain "mailto" anywhere as a value for their "href" attribute ad hence they can parse the real email address. (Most professional harvesters are smarter and also scan javascript for emails and hence a server side solution is always preferred than this or anyother client based solution).

"& # 109;" is the ascii code(without spaces) for letter "m", so we first try and hide this letter in the above code. We also try and remove "@" and replace it with "at" and so on.. to make it harder and harder for the bots to understand the email address. We end up with

Email Me (& # 109;ailto:abc_at_NOSPAM_xyx_dot_com)

(Remember to remove the spaces from "m"'s ascii code)

Now without any javascript on the page, if the link is clicked the email client will open up because the browser understands the "& # 109;" and subsequently the mailto link. But the email address in the "To:" box of the email client will contain abc_at_NOSPAM_xyx_dot_com. A human would probably figure out by reading the link that it is actually abc@xyz.com. To make it further idiot proof, you may want to replace the text link "Email Me" with an gif image of the real email address.

Now if the script is used and javascript is turned on, then the javascript converts "& # 109;ailto:abc_at_NOSPAM_xyx_dot_com" to "abc@xyz.com" and the email client gets the real address.

Attached is a dreamweaver extension for this script