protecting E-mail Address on web pages with php, javascript from E-mail spammers
E-mail Spam is flooding the Internet with many copies of the same message, in an attempt to force the message on people who would not otherwise choose to receive it.Most spam is Commercial advertising, often for dubious products, get-rich-quick schemes, or quasi-legal services. Spam costs the sender very little to send — most of the costs are paid for by the recipient or the carriers rather than by the sender.
How do they catch email address of users? Or how do they email harvesting?
There are many ways to get users email address but here we talk about only two ways.
From web pages:
Spammers have programs which spider through web pages, looking for email addresses, e.g. email addresses contained in mailto: HTML tags [those you can click on and get a mail window opened],a word contains @ symbol ,a word contains mailto:
From various web contact or enquiry forms.
Some sites request various details via forms, e.g. guest books & registrations forms.
Spammers can get email addresses from those either because the form becomes available
on the world wide web, or because the site sells / gives the emails list to others.
some spammers use weak security web forms on certain websites to protect web form from spammers please refer my post
Preventing E-mail harvesting on web pages
e-mail Address munging or e-mail Obfuscation
Address munging is the practice of disguising, or munging, to prevent it being automatically collected by spam bots.
Some examples are
- no-one at example (dot) com
- no-one@elpmaxe.com.invalid
- moc.elpmaxe@eno-on
- no-one@exampleREMOVEME.com.invalid
- remove .invalid
- no-one@exampleNOSPAM.com.invalid
- n o – o n e @ e x a m p l e . c o m
- no-one@example.com (as HTML)
Even though the email harvesting reduced in measurable amount, with this method the main user has to predict the original. Now days some spam bots also overcomes this method.
Using javascript
Most of the spam bots don’t execute the javascript and they use regular expression to catch the address.
So we can advance the method of munging with following examples
For static web pages e-mail Obfuscation
1 2 3 4 5 6 | <script type="text/javascript"> var name = 'user'; var at = '@'; var domain = 'example.com'; document.write(name + at + domain); </script> |
1 2 3 4 | <script> document.write(‘m’+’y’+’m’+’a’+’i’+’l’+’ @’+’y’+’o’+’u’+’d’+’o’+’m’+’a’+’i’+’n’+’ .’+’c’+’o’+’m’); </script> //In the above example we use html equivalent ASCII chars @ for symbol and . for ‘.’ Character. |
For dynamic web pages with PHP server side language e-mail Obfuscation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | function safe_asciimail($email){ $length=strlen($email); if($length==0)return ''; $email=strtolower(trim($email)); $email_array=str_split($email); $ascii_email_array=array(); for( $i=0;$i<count($email_array);$i++){ $c=$email_array[$i]; $ascii_email_array[]='&#'.ord($c).';'; } return '<script> document.write("'.implode('',$ascii_email_array).'");</script>'; } //We can call this method as follow //safe_asciimail(‘mymail@yourdomain.com’); |









Related Articles
2 users responded in this post
[...] Spam bot is a program that submits the data to server by guessing form fields with html code. For detailed article please refer my previous post. [...]
If you’re a Mac user, you could use a Dashboard widget called obfuscatr which is the email obfuscation widget. Uses similar logic to the above, just stronger encoding.
Leave A Reply