Banning Email Addresses With Any Perl Script
Once in a while, we receive inquiries about how to ban
email addresses with this or that Master Series script.
One arrived last week. This time, rather than composing a
custom solution, I decided to write an article about how to
do it with pretty much any Perl script. I can then refer
to the online version of the article when responding to
future inquiries.
There are 3 steps to add a banned email address feature to
a Perl script.
The first two steps are identical for any script. The third
step, the customization of one line and where that line will
be inserted, will vary from script to script.
Doing these steps will cause the script to spawn an Internal
Server Error if a banned email address is found.
Here are the steps.
Step 1:
Create a plain text file named EmailBanned.txt (case
sensitive file name) for the banned email addresses.
Addresses can be any of two forms, complete addresses
(like name@example.com, which would ban the email address
name@example.com) or domain addresses (beginning with @)
(like @example.com, which would ban all email addresses at
@example.com).
Addresses can be put in the file one per line or any other
way so long as there is a space, a line feed, and/or a
comma (or any combination or repetitions thereof) between
each address.
Upload the EmailBanned.txt file into the directory where
the Perl script is running. That will work for most
Unix/Linux servers.
Test it after completing all steps. If the EmailBanned.txt
file isn't being read, your hosting company may have the
"current working directory" set to be something other than
where the script is running, in which case they will need
to let you know where to put the EmailBanned.txt file.
Step 2:
Copy 'n paste the subroutine EmailBanned (below) into your
script.
It can't be put within other subroutines, but pretty much
anywhere else is okay. If in doubt, put it at the end of
the script unless there is a "__END__" line in the
script, in which case put the subroutine above the
"__END__" line.
Here is the subroutine.
Step 3:
This is the hardest step. If you're not proficient with
Perl, it may be prudent to ask the programmer of the script
for help.
Determine the variable name where the email address is
stored. Use that variable name between the inner parenthesis
of this line:
Insert the line, with VARIABLENAME replaced, somewhere in
the program after the form contents have been received and
before the email address is acted on.
Instructions for several Master Series programs are below.
If you wish to have something else happen than spawning an
Internal Server Error when encountering a banned email
address, replace the "exit" call with something else. As
an example, if you wish to redirect the user to
http://example.com/page.html, replace
with
Step 3 instructions for individual Master Series scripts:
(Line numbers assume latest version.)
Master Feedback
At line 110, insert the line
You'll end up with
Master Recommend V3
At line 675, insert the line
You'll end up with
Master Form V4 (just script MasterFormV4.cgi)
At line 1045, insert the line
(must replace FIELDNAME with the form field name containing the email address)
You'll end up with
Master Form V3
At line 1313, insert the line
(must replace FIELDNAME with the form field name containing the email address)
You'll end up with
Master Info Relay V3 (just script mir.cgi)
At line 252, insert the line
You'll end up with
Master E-Responder V2 (just script MEsubform.cgi)
At line 141, insert the line
You'll end up with
Master Autoresponder Bank (two scripts need to be changed)
(1) script MasterAutoresponderBankForm.cgi
At line 131, insert the line
You'll end up with
(2) script MasterAutoresponderBankEmail.cgi
At line 151, insert the line
You'll end up with
Those 3 steps will let you ban email addresses as needed.
Simply add or remove addresses in the EmailBanned.txt file
as warranted.
I realize step 3 is a stumbler. Without being familiar with
the script you may want to upgrade with the banned email
address feature, I simply can't be more specific. But it
almost certainly can be done with any Perl script that
processes form information submitted to it.
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©Copyright 2006 Bontrager Connection, LLC Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.