Tiny Tips 3 – Email Mungling

Protecting your email from SPAM sources is on the “important things that needs to be taken care of” list when we come up with websites. Normally, when we make our email available through website in plain text the email harvesting bots from SPAM source are able to retrieve them for spamming purposes. But taking of the plain email links will lead to other complications like deploying a flash based movie with emails which will cause troubles for users without flash plug-in and so on.

The best way to deal with this problem is to use a email munger. Email munger is an application which will take in a plain looking email address (eg. [email protected]) and change the characters to ASCII codes so that the spam bots wont recognize them as emails example:

1
whosthere@nowhere.mymy

In the above case the email [email protected] was converted into HTML escaped ASCII encoded string by email munger. Even though spam bots wont be able to recognize the text browsers will not have any problem reading / parsing them.

Below is the sample code in C# for converting a plain email to its munged form:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
public static string GetMungedEmail(string plainEmail) {
   StringBuilder finalEmail = new StringBuilder(plainEmail.Length * 6); // Approximately each character of the plain email takes 6 charater in encoded form
   foreach (char c in plainEmail.ToCharArray()) {
     finalEmail.Append("&#");
        finalEmail.Append(((int)c).ToString());
        finalEmail.Append(";");
   }
 
   return finalEmail.ToString();
 }

As you can see all the fun happens at line 5 where we convert the character to its ASCII equivalent.

Related Links:

Automatic Email Munger, An antispam tool for hiding your email address in a web page from spamrobots by Daniele Raffo

Email munger (to help you minimise email spam)

comments powered by Disqus