Email List Manager

There are many ways to keep track of who visits your web site. One of the simplest involves asking each user for an email address. That way, you'll be able to notify them of changes and enhancements to your web site. Using something like:

Now, on your web server, you'll need a way to collect these email addresses. Also, it would be helpful if a user could easily remove his or her email address from your list. Using the script presented this week, you'll be able to add, delete and view the users on your mailing list. In Part II (coming sometime in the future), you'll be able to automatically send a message or newsletter to everyone or just selected members on your mailing list.

Design

The approach that I took to design this program is rather straightforward. When the user enters an email address, the current database is searched. If the user is not in it, the address will be added. If, however, the user's name is in the list, it will display a message asking if the address should be removed. In this way, an address can be added or removed with a minimum amount of hassle.

This also presents the primary weakness in the design: Anybody can enter any email address. If you want to sign up billg@microsoft.com, there's nothing to stop you. So, as the administrator of the list, you'll need to be careful to not let it turn into a spamfest.

When an address is added or removed, the script uses html files to format and display the its messages. All the files used by the script are stored in a single directory, named $HOME in the Perl source file. Here's a list of the files that it uses:

badaddr.html Used when user gives an invalid email address
byebye.html Displayed after user is deleted from the list
notfound.html Address not found; couldn't be deleted
thanks.html Displayed after a user is added to the list
onlist.html Asks if the address should be deleted or remain on the list
badpass.html Displayed if the admin password is incorrect.
error.html Displayed if an error occurs

Another feature is that the current contents of the list can be displayed and edited.
The figure above shows how the list is divided into two sections. The top list shows the "active" users who want to be on the mailing list. The lower part shows members who have been "deleted" from the list. In fact, they're just in the inactive section. Clicking on "Delete" or "Undelete" will move a name between the inactive and active lists. Clicking on the email address will immediately let you send an email message to that user only. Of course, this list can only be displayed if the admin password for the script is given. (See $PASSWORD in the Perl source file).

Try out the working demo.

Then, download the entire source code package. Before using the source files, you'll need to modify at least the index.html and elist.pl files to work on your system. The file index.html should have the <form action=... > tag set to point to the cgi-bin directory on your web server. Then, elist.pl (the main script), will need to be edited. The $HOME variable should be the path where you stored the other html files and email name list (emaillist.txt) that the script will use. Finally, set the protection on emaillist.txt so that the web server can read and write to it.

Part II will appear soon.

Author: Doug Steinwand
Date: [08/31/97]

More articles about CGI
More articles by Doug Steinwand
Author Biography

/body>