The process of constructing your own mailing list is easier than you think. We'll show you how to do it with Perl.
Web businesses set up mailing lists for a variety of reasons: so that users can be notified of any new changes to your site, or so that you could send your users information about any special sales you may be having.
September 1, 1997
At meep! media, we use a mailing list to inform subscribed users about changes
to our magazines, Web Tech and Net Worth. It
is basically a form that asks for the user's email address, which is
then processed by a CGI script that mails the email address to a
pre-determined person whose mail software will then add the user's
address into a mailing list. The process of constructing your own
mailing list is easier than you think. We'll show you how.
Ingredients you'll need:
Web account that allows CGI perl scripts
knowledge about setting up CGI scripts on Web account
ability to add HTML code to your existing pages
mail software that has the ability to filter mail (Pegasus, Eudora Pro, BeyondMail, etc).
Instructions:
You will need to decide which page(s) you want to put the form. We'll use Web Tech as our example. This is the HTML code we used in our index page:
<FORM ACTION="/cgi-bin/maillist" METHOD=post>
<INPUT TYPE=hidden NAME="list" VALUE="web-tech">
<STRONG>Enter your e-mail address here to receive updates.</STRONG>
<INPUT TYPE=text NAME="email" SIZE=30>
<INPUT TYPE=submit VALUE="Keep me updated!">
</FORM>
The important thing to notice is the value of the input
list.
Because we use the same CGI script to process both of our
newsletters, this is how the mail filters recognize which newsletter
to process. You can change the value from
web-tech
to any other name you wish. Also be sure to change the
ACTION to the appropriate CGI script.
The CGI script that we wrote was written in perl. Take a look at
the source first. The most
important thing about the script is that it sends the mail with the
subject line as: subscribe web-tech. The
web-tech will change depending on what you
put as the value in the HTML code above. This subject line is what
your mail software use to distinguish between this kind of subscribe
message and your other email.
When you or the person in charge of the mailing list receives the
mail, your mail software will begin the process of handling the
subscribe message. But first you have to set it up so it knows what
to do. We'll use Pegasus Mail version 2.42 as an example, but
Eudora Pro, BeyondMail and other mail software also have similar
configuration steps.
Pegasus Mail and mail-filter rules
Pegasus Mail, like other mail software, has mail-filtering rules to
sort your mail. We use these filter rules to accomplish three
steps:
Automatically send a message to the user acknowledging their
subscription
Place the user on a mailing list
Move the subscribe message to a storage folder once you have had
a chance to look at it.
We use the mail filter to setup a rule for each of these steps.
First, create a mailing list (it's called distribution list in
Pegasus). You can find it in the Addresses menu or
by pressing F6. Click New List,
enter the name of the list, and click OK.
Next, you have to create a mail folder where these subscribe
messages can be stored. Go to your mail folders window
(Ctrl-L or File | Mail Folders)
and create a new mail folder.
Third, create a file with the text that you want to automatically
send to the user. Things that you can write include a little
introduction about the list, how many times a month the newsletter
is sent, and information about how to unsubscribe (we'll get to that
later). This is also a good time to create a file for when the user
decides unsubscribe from your newsletter.
Creating the mail-filter rules
Once you have finished the above steps, then you can create the mail
filter rules. Go to the File menu and select
Mail filtering rules | edit new mail filtering rules | rules
applied when folder is opened. Alternatively, you can
click on the button that has a red funnel and a blue arrow pointing
down.
To create the first rule of automatic replying to the user,
click on Add Rule, and click on In these
headers and Subject:.
This tells the Pegasus to look for the trigger text only in the
Subject header of the mail message. What's the
trigger text? It's the text that identifies the email as a
subscribe message, and in our case, it's subscribe
web-tech. So we enter subscribe
web-tech into the Trigger text field.
Now that we have established the rule for picking which message to
act upon, we need an action. In our case, they are the 3 steps that
we want accomplished. So first we'll use the action to send an
automatic reply to the user. Choose Send text file
in the Action to take field, and a dialog box will
pop up asking you for the location of the file. Choose the file
that you created earlier, and click OK. That's it,
the first rule is completely done!
The other two rules are similar, except for the action to take. For
adding the user to a mailing list choose the Add user to
list option and for moving the message into a mail folder
use the Move option.
Unsubscribe is important too!
You also have to have a mechanism for users who may want to
unsubscribe from your newsletter. You should include in the
automatic reply a line or two about unsubscribing. Our procedure is
to reply with a unsubscribe web-tech in the message.
Unsubscribing involves the same steps as subscribing, except for the
reverse actions that need to be acted upon.
Once you're finished with the whole setup, it would be prudent to
check it first by subscribing your own email address as a test. Go
through the whole subscribe and unsubscribe procedure and make sure
that each step has been executed correctly.
Rodney Chang is a co-owner of meep! media inc., an Internet and Intranet
consulting company. He is also one of the
programmers, specializing in CGI (Perl), Javascript and database integration.