ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 CoverYourASP --> Fighting email abuse --> Part 2

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
136 active users
3061 visitors today
2980 pages today
(only part of today)
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

CoverYourASP
Copyright © 1999-2008 James Shaw.
All rights reserved.

ASP.NET Blog
ASPRSS
ShawThing

Now open source with SourceForge!

The IsEmailBlocked( ) function

First I added the following lines to the top of my SendEmail function that is used throughout the site: (you might want to read my article about sending email if you haven't already)

function SendEmail ( sFromEmail, sToEmail, sBccEmail, sSubject, sBody )
{
   if ( IsEmailBlocked ( sToEmail ) )
      return;

This tests the email address and doesn't send the email if it fails.

The IsEmailBlocked function, also in utils/Email.asp, is very simple. Today, with a single blocked email in the list, I don't even use a database, opting instead to keep the list of blocked emails in a global variable, sBlockedEmails.

// ============================================
// check that email hasn't been blocked to this address. send all data
// to webmaster (and optionally to blocked sender) if it has.
// ============================================
function IsEmailBlocked ( sEmail )
{
   // make lowercase for the comparison
   var sTest = '>' + sEmail.toLowerCase ( ) + '<';

   if ( -1 != sBlockedEmails.indexOf ( sTest ) )
   {

The email addresses are converted to lowercase characters and wrapped in >< to ensure that only the correct matches are found. If a match is found a new email is sent ot me, and the function returns true.

   // this email is blocked, so send me an email
   var sBody = 'Someone has attempted to cause email to be sent to the email address "' + sEmail + '". As requested, the CoverYourASP site has blocked access to this email address. Below is all the information I could gather about the perpetrator:\n\n';

   sBody += 'HTTP_USER_AGENT: ' +Request.ServerVariables ( 'HTTP_USER_AGENT' ) + '\n';
   sBody += 'REMOTE_ADDR: ' +Request.ServerVariables ( 'REMOTE_ADDR' ) + '\n';
   sBody += 'SERVER TIME:' + new Date + '\n\n';

   sBody += 'If you have any questions about this email, or wish to stop receiving these notices of attempted abuse, please reply to this email.\n\nMember Services\nhttp://' + sHostDomain;

   SendEmail ( 'MemberServices@' + sHostDomain, 'Abuse@' + sHostDomain, '', 'Email blocked', sBody )

   return true;
}

Featured sponsor
My favorite resources

Selling products online - read how James does it now


CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?


New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!