Every time an email address is written on a website, it allows spam robots to collect it and abuse it. If you have a website (e.g. blog or forum) that displays the users e-mail address it would be a nice service to mask it for the spam robots.
function SendMail(name, company, domain)
link = 'mai' + 'lto:' + name + '@' + company + '.' + domain;
Then call that method with a hyperlink like this:
That will make it pretty difficult to parse for a spam robot.
Another approach is to encode the characters into hex code which is perfectly readable for all browsers, but can proof to be more difficult to parse by robots but not impossible. What a robot can do is to just decode the entire HTML document from hex values into clear text, which will expose the e-mail addresses. But if we mixed clear text and hex values it will be much more difficult for the robot. That’s what the following HttpModule does.
The module replaces all e-mail addresses on your website with the mixed hex/clear text characters. It turns this
It uses the System.Random class to do the mix of the clear text with the hex values. The primary methods in the modules are the ones that through regex, replaces the clear text addresses.
private static Regex _Regex = new Regex("(mailto:|)(\\w+[a-zA-Z0-9.-_]*)@(\\w+).(\\w+)");
private static Random _Random = new Random();
private static string EncodeEmails(string html)
foreach (Match match in _Regex.Matches(html))
html = html.Replace(match.Value, Encode(match.Value));
private static string Encode(string value)
StringBuilder sb = new StringBuilder();
for (int i = 0; i < value.Length; i++)
if (_Random.Next(2) == 1)
You can add this module to any existing web applications without breaking any code. Download the EmailSpamModule.cs below and place it in the App_Code folder on your website. Then add the following to the web.config:
<add type="EmailSpamModule" name="EmailSpamModule" />