PHP
  Home arrow PHP arrow Page 2 - Create Your Own Mail Script With PHP and I...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
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? 
PHP

Create Your Own Mail Script With PHP and IMAP
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 92
    2002-03-25

    Table of Contents:
  • Create Your Own Mail Script With PHP and IMAP
  • What is IMAP?
  • IMAP functions
  • Creating our email script
  • The ShowEmail function and more
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


    Create Your Own Mail Script With PHP and IMAP - What is IMAP?


    (Page 2 of 6 )

    IMAP is a method of accessing email messages stored on a remote mail server. The reason IMAP is so popular is because it allows clients to connect to and interact with their mail server without the need to download their emails and files locally. In other words, IMAP allows us to treat a remote mail server as is if it was on our local machine, checking our accounts, manipulating emails, replying to emails, etc.

    IMAP shouldn't be confused with the POP3 protocol, however. If you've ever used Outlook or Eudora or any other client mail access program, then you'll know that you can "check" your email, disconnect from the Internet and your mail will be stored on your local machine, saving you the hassle of being on the 'net to read your email. This is POP's biggest advantage: offline access to your email. POP downloads all new messages off the server onto your local PC and then deletes them from that server. IMAP on the other hand queries the server, leaving all emails intact unless you specifically tell it to delete them.

    POP was designed for use with client side email applications such as Outlook, whereas IMAP was designed for people on the move, wanting to check their email but not necessarily retrieve it.

    The key goals for IMAP are:
    • Be fully compatible with Internet messaging standards, e.g. MIME.
    • Allow message access and management from more than one computer.
    • Allow access without reliance on less efficient file access protocols.
    • Provide support for online, offline and disconnected access modes.
    • Support for concurrent access to shared mailboxes.
    • Client software needs no knowledge about the server's file store format.
    Let's take the last point into configuration: "Client software needs no knowledge about the server's file store format". In my opinion this is one of IMAP's best features. The client simply queries the mail server using IMAP specific commands and that server returns the data the client's after.

    It doesn't matter how the server stores the actual email messages (whether it be in a flat file, a MySQL database, an MSSQL server database or any other format) as long as the server returns the data that the client requests, then the storage method and location are irrelevant.

    Bringing PHP into the picture

    If you've worked with PHP extensions then you'll know that it supports IMAP through an extension library, which isn't installed by default. Before we can play around with PHP and IMAP, we have to install the necessary IMAP libraries first.

    Configuring PHP on Windows with IMAP support

    It's easy to configure your Windows server to work with IMAP. Firstly, grab the php_imap.dll file from your PHP download (it should be in the extensions directory). If you can't find it then download the PHP zip package here.

    Next, copy php_imap.dll to your PHP extension directory, which you can find in your php.ini file as the extension_dir variable. Lastly, open php.ini and look for the line starting ";extension=php_imap.dll". Remove the semicolon from the front, save the file and restart your web server.

    Configuring PHP on Linux with IMAP support

    To enable IMAP support on your PHP installation you need to compile PHP with the --with-imap argument. You also need to download the IMAP library here. Once you've downloaded it, copy c-client/c-client.a to /usr/local/lib/libc-client.a. Also copy c-client/rfc822.h, mail.h and linkage.h to /usr/local/include or some other directory in your include path.

    Testing for IMAP support

    To make sure IMAP support is configured correctly, create a new file called phpinfo.php and save it into a directory that your web server can process. Add the following code to it and run it in your web browser:

    <?php echo phpinfo(); ?>

    Scroll down the page about half way and look for the IMAP section. You should see something like this:

    Making sure IMAP was configured OK

    Now that we've setup IMAP support, it's time to take a look at the various IMAP functions that we will be using later in this article to create our email script.

    More PHP Articles
    More By Mitchell Harper


       · An excellent imap tutorial for beginners which gets them started with coding imap...
       · I just think the tutorials is not comprehensive enough for one to follow through....
     

    PHP ARTICLES

    - Making Usage Statistics in PHP
    - Installing PHP under Windows: Further Config...
    - File Version Management in PHP
    - Statistical View of Data in a Clustered Bar ...
    - Creating a Multi-File Upload Script in PHP
    - Executing Microsoft SQL Server Stored Proced...
    - Code 10x More Efficiently Using Data Access ...
    - A Few Tips for Speeding Up PHP Code
    - The Modular Web Page
    - Quick E-Commerce with PHP and PayPal
    - Regression Testing With JMeter
    - Building an Iterator with PHP
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT