Home arrow PHP arrow Page 2 - Building A PHP-Based Mail Client (part 3)

Composing Yourself - PHP

This third (and final) segment of our case study discusses theprocess of sending MIME-encoded email, demonstrating how to compose,forward and reply to email through a Web browser. It also discusses, indetail, the process of constructing a MIME-encoded message withattachments, explains PHP's HTTP upload capabilities, and examines thestandard error handler used throughout this case study.

TABLE OF CONTENTS:
  1. Building A PHP-Based Mail Client (part 3)
  2. Composing Yourself
  3. Return To Sender
  4. Coming Forward
  5. Setting Boundaries
  6. Under Construction
  7. When Things Go Wrong...
  8. Game Over
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 8
January 23, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
You'll remember, from our discussion of the "view.php" script, that the generated page includes a series of command buttons at the top.

<!-- command buttons from view.php --> <!-- some HTML snipped out for readability --> <td><a href="compose.php">Compose</a></td> <td><a href="reply.php?id=<? echo $id; ?>">Reply</a></td> <td><a href="forward.php?id=<? echo $id; ?>">Forward</a></td> <td><a href="delete.php?dmsg[]=<? echo $id; ?>">Delete</a></td> <td><a href="list.php">Messages</a></td>
The first (and simplest) of these is the "compose.php" script, which merely creates a blank form representing a new email message.

<? // compose.php - compose new message // includes and session check ?> <html> <head> </head> <body bgcolor="White"> <? // page header ?> <!-- commands - snipped --> <table border="0" cellspacing="1" cellpadding="5" width="100%"> <form action="send.php" method="post" enctype="multipart/form-data"> <tr> <td valign=top><font face="Verdana" size="-1"><b>From: </b></font></td> <td valign=top width=100%><input type="Text" name="from" size="30" maxlength="75" value="<? echo $SESSION_USER_NAME . "@" . $SESSION_MAIL_HOST; ?>"> </td> </tr> <tr> <td valign=top><font face="Verdana" size="-1"><b>To: </b></font></td> <td valign=top><input type="Text" name="to" size="30"></td> </tr> <tr> <td valign=top><font face="Verdana" size="-1"><b>Cc: </b></font></td> <td valign=top><input type="Text" name="cc" size="30"></td> </tr> <tr> <td valign=top><font face="Verdana" size="-1"><b>Bcc: </b></font></td> <td valign=top><input type="Text" name="bcc" size="30"></td> </tr> <tr> <td valign=top><font face="Verdana" size="-1"><b>Subject: </b></font></td> <td valign=top><input type="Text" name="subject" size="50"></td> </tr> <tr> <td valign=top><font face="Verdana" size="-1"><b>Message: </b></font></td> <td valign=top bgcolor="White"><textarea name="body" cols="60" rows="15" wrap="VIRTUAL" ></textarea></td> </tr> <tr> <td valign=top><font face="Verdana" size="-1"><b>Attachment: </b></font></td> <td valign=top bgcolor="White"><input type="file" name="attachment" size="20"></td> </tr> </form> </table> </body> </html>
Here's what it looks like:



There are a couple of things to be noted here. First, the

<input type="file" name="attachment" size="20">
construct near the end of the form. This form construct creates a "Browse..." button on the form, which allows for file selection and upload through the browser; I plan to allow the user to upload message attachments though this construct.

Second, note the form encoding type and method:

<form action="send.php" method="post" enctype="multipart/form-data"> <!-- snipped out HTML --> </form>
This encoding type and method must be specified whenever you attempt file upload over HTTP. PHP's official site has a manual page devoted to the topic - take a look at http://download.php.net/manual/en/features.file-upload.php and then come back for more.

 
 
>>> More PHP Articles          >>> More By icarus, (c) Melonfire
 

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: