You are viewing a plain-jane printable version of http://CoverYourASP.com/Abuse2.asp.
See how this was done

 

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;
}