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
13 active users
465 visitors today
376 pages today
(only part of today)
Tools I use

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

ASP.NET Blog
RSS submissions
E-commerce

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


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...


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!