Home arrow PHP arrow Page 3 - PHP Email

The Database - PHP

In this four-part series of articles we are going to build an email client with PHP. I will try to implement a full email client with all the functionality that you would expect from an email client, which includes a trash folder, sent items folder and a draft folder. But that's not all.

TABLE OF CONTENTS:
  1. PHP Email
  2. How it Works
  3. The Database
  4. More Tables
By: Leidago
Rating: starstarstarstarstar / 11
October 25, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

When the application downloads messages from the server, it will immediately send them to the database and then retrieve them to show on the index page. So in effect, you will be viewing messages that are retrieved from a database instead of messages that are directly downloaded from a mail server.

In addition to storing messages, the database will be used to store all messages that are classed as trash, drafts and sent items. So as you can appreciate, the database is very important to this application. Below I've listed all of the tables (along with the appropriate pieces of code) that are used by this application.

The contacts table will contain the names and email addresses of your contacts. It is linked to the users table through the userid foreign key, called "userid":

CREATE TABLE `contacts` (
  `contact_id` int(11) NOT NULL auto_increment,
  `name` varchar(100) NOT NULL default '',
  `email` varchar(100) NOT NULL default '',
  `userid` int(11) NOT NULL default '0',
  PRIMARY KEY  (`contact_id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;
INSERT INTO `contacts` VALUES (1, 'Joe Blogg', 'admin@mysite',
1);
INSERT INTO `contacts` VALUES (2, 'Joe Bloggs', 'admin@bloggs.com', 1);

Next, the calendar table is used to store information about dates and times for events. The user is connected to this table by the foreign key called "userid." This ensures that only entries made by this user are retrieved when requested.

CREATE TABLE `calendar` (
  `userid` int(11) NOT NULL default '0',
  `calendar_id` int(11) NOT NULL auto_increment,
  `cal_date` date NOT NULL default '0000-00-00',
  `entry` text NOT NULL,
  PRIMARY KEY  (`calendar_id`)
)  TYPE=MyISAM AUTO_INCREMENT=3 ;

INSERT INTO `calendar` VALUES (1, '2005-12-08', 'This encompasses more than the OED definition of a conflict as "a state of opposition or hostilities" or the "clashing of opposed principles". Horowitz's definition includes the desire to achieve something by the struggle, as well as the need for prevailing over an 'other': both elements of ethnic conflict. rnrnThere are a great many theories attempting to explain why groups find themselves in conflict situations. With ethnic groups in particular, why is it so difficult to find resolutions before violence occurs, and why are people so willing to give up so much, often their lives, for their ethnic group? This presentation deals with conflict between ethnic groups primarily, and it is for ethnic groups that this phenomenon of putting the interests of the group before those of the individual is so widespread. rn');

INSERT INTO `calendar` VALUES (2, '2005-12-28', 'This encompasses more than the OED definition of a conflict as "a state of opposition or hostilities" or the "clashing of opposed principles". Horowitz's definition includes the desire to achieve something by the struggle, as well as the need for prevailing over an 'other': both elements of ethnic conflict. rnrnThere are a great many theories attempting to explain why groups find themselves in conflict situations. With ethnic groups in particular, why is it so difficult to find resolutions before violence occurs, and why are people so willing to give up so much, often their lives, for their ethnic group? This presentation deals with conflict between ethnic groups primarily, and it is for ethnic groups that this phenomenon of putting the interests of the group before those of the individual is so widespread. rn');

The purpose of the Drafts table is to store all the mail messages that you want to write but don't want to send immediately.  It also links the user through the foreign key.

CREATE TABLE `drafts` (
  `draft_id` int(11) NOT NULL auto_increment,
  `to` int(200) NOT NULL default '0',
  `from` varchar(100) NOT NULL default '',
  `subject` varchar(200) NOT NULL default '',
  `msg_body` text NOT NULL,
  `userid` int(11) NOT NULL default '0',
  `cc` varchar(100) NOT NULL default '',
  `bcc` varchar(100) NOT NULL default '',
  `attachment` varchar(200) NOT NULL default '',
  PRIMARY KEY  (`draft_id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;



 
 
>>> More PHP Articles          >>> More By Leidago
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: