Internal Email System (PM)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

Internal Email System (PM)

Post by ericburnard »

Hi again.

I have been looking around on the net to try and find out how i can have an internal mailing system (privte mesaging) so that after my users have logged in the can send messages to the user's in their address book.

I hav a very very vague idea of how to do this, but if anybody has one on their site or knows of one or knows how to make one then help would be greatly acepted :d

Thanks
Eric
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Private Messaging like the way its done here (devnet forums) and other forums etc dont use mail features - it just sends the msg internally stored in the database to the recipient's Inbox (marked in the table) - This is totally within a single server.

Mail on the other hand is sent through Ports to any server in the world.
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

Post by ericburnard »

well thats the kind of thing i am looking for where i stores it in a database and then can be view by a certain member to who it was sent to.

Eric
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

I put together a pm system a little while ago, like anjanesh said, the data is just inserted in to a db.

I assume you have a membership system .. If so just create a form with fields

to:, subject:, message.

post that data to a sql INSERT query:

Code: Select all

$sql = mysql_query("INSERT INTO pm (user_name, subject, message, sender, sent, new, date)
       VALUES('$user_name', '$subject', '$message', '$sender', '1', '1', now())") or die (mysql_error());

$sql = mysql_query("INSERT INTO pm (user_name, subject, message, sender, sent, date)
       VALUES('$user_name', '$subject', '$message', '$sender', '0', now())") or die (mysql_error());
I create 2 querys, one is the data for the senders "sent items" and the other for the recievers inbox.

Other fields were added as yu can see above so you can query the table for the correct data.

user_name so you can query WHERE user_name = '$user_name'

new: query whether it is new mail.
sent: to query and show the pm message in the senders sent items.
date: using now() to insert date & time so it can be called on to show dates pm messages were sent.

Then you create your other pages (querys) toi grab the inbox data, send data, and also add your delete etc etc functions.

I created 4 pages:

inbox.php = lists inbox pm messages
sent.php = same as inbox.php but lists sent pm messages
read.php = shows the pm message for reading (with reply and quote reply) links
pm_parse.php = All my functions (querys) to run the pm system.

SQL Dump I used:

Code: Select all

CREATE TABLE pm
(
id int(6) NOT NULL auto_increment,
user_name varchar(255) NOT NULL,
subject varchar(255) NOT NULL,
message varchar(255) NOT NULL,
sender varchar(255) NOT NULL,
sent varchar(255) NOT NULL,
new varchar(255) NOT NULL,
date datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY  (id)
) TYPE=MyISAM;
Im not a very good explainer, but there is some food for thought, should be enough to give u the basic concept ..

hth
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

Post by ericburnard »

wow thanks for that :D its great i will have a play around with it tomorow and see if i can get some stuff working.
If i get into any trouble would you mind me pm you??

Thnaks again
Eric
Post Reply