Home Home -> Net Tips

Fighting the Spammers

One of the major problems of running a public website is dealing with unsolicited bulk email, or "spam". I prefer to make my email address available freely, so it is easy to get in touch. Unfortunately, this leaves it open to spammers, the people who send the unsolicited email.

The people and companies who send bulk email are under the misguided impression that it will produce results - in reality, it produces a nasty backlash. If you're thinking of sending spam, don't. In the rest of this article I'll cover my pet hates regarding spam, followed by the methods now being employed on this website to fight the spammers.

Pet Hates

  • Spam only relevant to the United States being sent to my .co.uk address (I didn't say spammers were very clever...).
  • Spam with "this is not spam, it complies with federal law" in it. Yes, it is spam. And I don't care about federal law, US congress or anything else in the US. Federal law does not apply to my .co.uk domain.
  • Spam selling email addresses to send spam to.
  • Christine Hall (who may or may not be a real person - if you've had an encounter with this name, you'll understand).

Defence Against Spam

Early Prevention

When examining spam defence, my first priority was to stop spammers getting hold of my address in the first place. Some already have it, but they can be dealt with separately. The easiest way would be to remove every email address from the website and have a contact form instead. I hate contact forms and prefer being able to click a link and send an email from my mail client, so that wasn't really an acceptable option. Any solution needed to fulfil the following requirements:

  • No email addresses should appear in an identifiable form (a form which an automated email-harvester could read)
  • Standard clickable email links must remain available for as many visitors as possible

The solution is fairly simple - for those browsers with JavaScript support, a simple script re-builds the email address when a link is clicked. Those browsers without JavaScript support simply get directed to a page where the email address is displayed on screen, but with additional "junk" HTML in between to disguise it. Since most visitors use Internet Explorer, clicking the link is generally all that is required.

The code below rebuilds a mailto: link from the username and domain:


//---------------------------------------------------------------
// Anti-spam JavaScript function
// You may reproduce this script, but please include this message
//---------------------------------------------------------------
// Copyright (C) 2002, Ashley Brown. http://www.ashleybrown.co.uk/
//---------------------------------------------------------------
function despammail(strUser, strDomain)
{
	document.location = "mailto:" + strUser + "@" + strDomain;
}


Within the HTML code, the email links look like the following:

<a href="/antispam.asp" onclick="despammail('webmaster', 'ashleybrown.co.uk');return false;" class="copyright">

-
FULL LIST OF STORIES
Fighting the Spammers
16 Jul 2002
One of the major problems of running a public website is dealing with unsolicited bulk email, or "spam". I prefer to make my email address available freely, so it is easy to get in touch. Unfortunately, this leaves it open to spammers, the people who send the unsolicited email.
By Ashley Brown
Too Much Flashiness
12 Apr 2005
My last Net Tips article on Flash 5 caused quite a stir, so this article clarifies some points and puts forward additional points of view.
By Ashley Brown
Don't Get Flashy...
28 Jan 2001
Many websites are relying increasingly on Flash and JavaScript to add a wow factor. However, this may not be such a good idea.
By Ashley Brown
User Friendliness
13 Nov 2000
Making your site user-friendly is important if you are going to keep your users. This article gives you some guidance about how to be nice to your visitors.
By Ashley Brown
Search Engines - Part II: Search Engines and Frames
19 Jul 2002
Using search engines with frame-based sites has always posed problems. Thanks to JavaScript you don't have to worry about these anymore.
By Ashley Brown
Search Engines - Part I: Get Listed
24 Oct 2000
The first Net Tips article examines the ways that you can get yourself listed favourably on the search engines.
By Ashley Brown