Home arrow PHP arrow Page 4 - Coding Folders for a PHP Email Application

The Sent, Trash and Drafts Folders - PHP

In this article, the fourth and final one of our series covering the creation of a PHP email application, we are going to look at the code for some of the remaining pages of the mail application. Chief among these is the NewMsg.php page, which is where items, to be more precise, new messages, are either saved as drafts or saved as sent messages.

  1. Coding Folders for a PHP Email Application
  2. Form Data
  3. Explaining Sections B and C
  4. The Sent, Trash and Drafts Folders
By: Leidago
Rating: starstarstarstarstar / 8
November 15, 2006

print this article



The above folders have similar code, so I'm not going to list the code of each of them here. Let me explain what happens when you want to view the items inside a folder. A query string variable called userID is received, which is used to retrieve messages related to that user. Then a query is run on the table of the related folder (can be the sent, trash or drafts table). Based on the results of that query, a dynamic table is created and all the messages are listed. Here's the code for the Sent folder:


                include "connect.php";

//get all msgs

                $query_msgs = "select * from sent WHERE userid =

                $re = mysql_query($query_msgs);

                $n = mysql_num_rows($re);

                if($n > 0){

                while($r = mysql_fetch_array($re))



<tr class="td">

          <td valign="top" class="list">

                                <a href="NewMsg.php?sid=<?=$r
['sent_id'];?>" class="email"><?=$r['to'];?></a>


                                 <td valign="top" class="list"><?
=$r['from']; ?></td>

          <td valign="top" class="list"><?=$r['subject']; ?></td>







That's it! You should now have a fully functional PHP email client. I've used very general code to make it easy for you to adapt it to your liking. The basics are covered, so any changes you make to this will just make your client more useful. In the NewMsgs page I've used a text editor called fckEditor because it makes it possible to format the text, and in so doing enables you to sent HTML email messages. You can download this editor from the Internet, it is entirely free. Also, if you do not want to use this editor, you can use the normal textarea form element instead.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: