Simple Cross Language Bulk Mailer Part 1
Posted on 20 Jul 2001
by Daniel Cody (djc)
Rated 4.13 (Ratings: 6)
- More articles in Backend
Spelling out our goals.
Now, what we're creating here is going to be an *extremely* simple mass emailer that will allowus to send a single email to many many people through a simple web form. This isn't to be confused witha full fledged mailing list manager(MLM) such as Mailman or Majordomo which would facilitate replies, digests, archives, etc. We're hereto do one(albeit simple) thing and do it well. However, we will build our application so that ifthe need arises for more features in the future, they won't be difficult to integrate intowhat we'll have already built. The first part of this article will deal with setting up the database structure, and talkingabout some of the high level goals we'll be trying to achieve. The continuation of this article will give examples in ColdFusion and PHP. Perhaps someone would like to also write ASP or JSP versions of the code using the strucutre we'llbe explaining today as a jumping point.
The database architecture.First off, let's get the database structure defined. We have three tables in our application; one for messages,one to keep track of users, and one to define lists. Here's the SQL and a basic description of each:
## Created in MySQL, adjust to taste.CREATE TABLE lists (list_id int(3) DEFAULT '1' NOT NULL,list_email varchar(50) NOT NULL,list_admin_id int(11) DEFAULT '0' NOT NULL,list_desc text NOT NULL,list_name varchar(50) NOT NULL,list_passwd varchar(50) NOT NULL,list_footer varchar(250) NOT NULL,UNIQUE list_id (list_id));So, our lists table has 6 values:
- list_id each list has unique numeric value, its our primary key(PK).
- list_email holds the value of what our list will show in the From: header of the email.
- list_admin_id is just a placeholder for future use and won't be used here.
- list_desc is a short description of our list.
- list_name is the name of our list, and what we'll use to authenticate administrators.
- list_passwd is the password used to gain access to the functions of our list.
- list_footer is a message that will get appended to each message sent out with information about our list.
# Table structure for table 'members'A description of the members table:
CREATE TABLE members (member_id int(1) DEFAULT '1' NOT NULL,member_fname varchar(50),member_lname varchar(50),member_email varchar(50) NOT NULL,member_level int(11) DEFAULT '0' NOT NULL,member_subscribed tinyint(1) DEFAULT '0' NOT NULL,member_created datetime NOT NULL,member_subscribedto int(11) DEFAULT '0' NOT NULL,UNIQUE member_id (member_id));
- member_id assign each member a unique id, our PK.
- member_fname first name of the member.
- member_lname last name of the member.
- member_email email address of the member.
- member_level placeholder for future features and won't be used here.
- member_subscribed 0/1 value to tell us if the member is subscribed or unsubscribed.
- member_created just a date/time stamp to see how long they've been subscribed.
- member_subscribedto id of the list they're subscribed to.
# Table structure for table 'messages'A description of the messages table:
CREATE TABLE messages (msg_id int(1) DEFAULT '1' NOT NULL,msg_from_id int(11) DEFAULT '0' NOT NULL,msg_body text NOT NULL,msg_date datetime NOT NULL,msg_list_id int(11) DEFAULT '0' NOT NULL,msg_subject text,UNIQUE msg_id (msg_id));
- msg_id a unique value for each message that is sent, our PK.
- msg_from_id placeholder for future features that won't be used here.
- msg_body the body of the email thats being sent out.
- msg_date a date/time stamp recording when the message was sent.
- msg_list_id a number that corresponds to a list_id in our lists table to track which message belongs to which list.
- msg_subject the subject of the email being sent.
Now that we've got the database foundation nailed down we'll continue with the Cold Fusion end of our application will look like in the next installation of this article. In following installments, we'll show how to provide the same functionality in PHP that uses the same foundation we've layed today. Hopefully, someone will also follow up with ASP and/or JSP versions of the code too. Stay tuned!