PHP
  Home arrow PHP arrow Page 6 - Building A PHP-Based Mail Client (part 1)
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Building A PHP-Based Mail Client (part 1)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 41
    2002-01-02


    Table of Contents:
  • Building A PHP-Based Mail Client (part 1)
  • Requiring Immediate Attention
  • Start Me Up
  • Fully Function-al
  • Opening Up
  • Calling The Exterminator
  • Back To Square One

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building A PHP-Based Mail Client (part 1) - Calling The Exterminator
    ( Page 6 of 7 )

    You'll remember, from the previous pages, that every message in the message list has a checkbox accompanying it. This box, if checked, indicates that the message is to be deleted from the mail server.

    If you take a close look at "list.php", you'll see that every checkbox is associated with the $dmsg array; once the form is submitted, this array will contain the numbers of all the messages selected for deletion. The "delete.php" script then needs only to connect to the mail server and iterate through this array, marking the specified messages for deletion.

    Yes, it really is as simple as it sounds - take a look at the script:

    <? // delete.php - delete messages // session check session_start(); if (!session_is_registered("SESSION")) { header("Location: error.php?ec=2"); exit; } // open POP connection $inbox = @imap_open ("{". $SESSION_MAIL_HOST . "/pop3:110}", $SESSION_USER_NAME, $SESSION_USER_PASS) or header("Location: error.php?ec=3"); // delete specified message numbers for($x=0; $x<sizeof($dmsg); $x++) { imap_delete($inbox, $dmsg[$x]); } // clean up and go back to list page imap_close($inbox, CL_EXPUNGE); header("Location: list.php"); ?>
    As always, the first step is to check for the existence of a valid session. Assuming that exists, a connection is opened to the mail server and the imap_delete() function, in combination with the contents of the $dmsg array, is used to mark messages for deletion (if you're familiar with the POP3 protocol, this is equivalent to sending a series of DELE commands to the server).

    It should be noted that imap_delete() merely marks messages for deletion; it does not actually remove them from the server. In order to actually erase the marked messages, it's necessary to specify the CL_EXPUNGE argument while closing the mailbox with imap_close() (an alternative here would be to use the equivalent imap_expunge() command).

    Once all messages have been deleted, the browser is redirected to the message list. Deleted messages should now no longer appear in this list.

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

       

    PHP ARTICLES

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek