[Zope] Re: Simple way to obfuscate email addresses to foil spambots?

Josef Albert Meile jmeile at hotmail.com
Fri Sep 12 12:35:32 EDT 2003


>Does anyone have any suggestions as the best way to, within Zope,
>obfuscate email addresses such that, when passed an email, a script
>obfuscates it from being picked up by email-address
>collecting robots?
>
>Or any other creative anti-spam tricks.. I work at an educational
>nonprofit and our spam load seems to be increasing exponentially..

In the past, I was using a Javascript that I translated to
python:
http://www.zope.org/Members/jmeile/email%20encoder

But for some reason it shows the real address on the html source on
netscape 4.x under zope. Without zope, the javascript works perfect
also in netscape 4.x.

Anyway, now I'm using this on the body of my pages:

<script language="JavaScript">jemail("username","domain","");</script>

or

<script 
language="JavaScript">jemail("username","domain","linkText");</script>

If you use the first call, then the text of the email link will be the 
e-mail
address. The second one allows you to specify a text, ie: 'Contact us'.

And the javascript code is:

function jemail(user, domain, text){
  if (text=='')
    document.write('<a href="'+'mailto:'+user+'@'+domain+'">'+user+'@' 
+domain+'</a>')
  else
    document.write('<a href="'+'mailto:'+user+'@'+domain+'">'+text+'</a>')
}

You can combine it with dtml like this:

def splitMail(myEmail):
  return myEmail.split('@')

Then:

<dtml-let splitedMail="splitMail(myEmail)" username="myEmail[0]" 
domain="myEmail[1]">
<script 
language="JavaScript">jemail("&dtml-username;","&dtml-domain;","linkText");</script>
</dtml/let>

And if you are using Zclasses or python Classes, then you can store
the encoded email as an attribute and you won't have to write the
ugly and long code again.

I'd like to use zpt, but I haven't had time to think about it.

Regards,
Josef

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail




More information about the Zope mailing list