Page 1 of 1

Internal Email System (PM)

Posted: Sun Jul 31, 2005 11:43 am
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

Posted: Sun Jul 31, 2005 12:22 pm
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.

Posted: Sun Jul 31, 2005 1:02 pm
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

Posted: Sun Jul 31, 2005 4:48 pm
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

Posted: Sun Jul 31, 2005 6:45 pm
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