Home arrow PHP arrow Page 2 - PHP Email

How it Works - PHP

In this four-part series of articles we are going to build an email client with PHP. I will try to implement a full email client with all the functionality that you would expect from an email client, which includes a trash folder, sent items folder and a draft folder. But that's not all.

  1. PHP Email
  2. How it Works
  3. The Database
  4. More Tables
By: Leidago
Rating: starstarstarstarstar / 11
October 25, 2006

print this article



I will be using PHP's imap functions to write this client. There are over sixty functions available that you can use to create a mail client for both POP3 and IMAP. Visit http://www.php.net/ to see what functions are available. We will be creating a mail client that supports POP3 because it is by far the most popular mail protocol used today. To send an email message with PHP is very simple. You just use PHP's mail() function. The syntax for the function is:

mail( string to, string subject, string message [, string
additional_headers [, string additional_parameters]] )

But because we want to give the user the choice to send attachments with email, we are going to use the freely available PHPMailer class (from http://phpmailer.sourceforge.net ). This class gives us the power to send email messages with all kinds of features, such as attachments, HTML messages or just plain messages. Although I will be using PHPMailer in this article, I will not be using it extensively, so please look at the following sites to learn more about this class:

Examples - http://phpmailer.sourceforge.net/extending.html

Tutorial - http://phpmailer.sourceforge.net/tutorial.html

To retrieve email messages from the mail server, we will be using the @imap_headerinfo() and imap_msgno( ) functions. The imap_headerinfo() function retrieves all the message headers such as from, subject, and so forth, and the imap_msgno() function identifies the message number as it is numbered on the server.

To connect to the mail server we use the imap_open($mbox, $userid, $userpassword) function. As you can see this function takes three parameters, the mailbox name, the user name and user password.

The application will provide the ability to do the following:

  • User authentication.
  • Connect to the mail server and download and process messages.
  • Store the messages in the database one by one.
  • Retrieve and display all the newly downloaded messages.

After the messages are displayed on the index page, the program will give the user the option to view a message (this will lead to the view.php page) or to delete the message.

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