XLII. IMAP, POP3 and NNTP functions
Introduction
These functions are not limited to the IMAP protocol, despite their name. The underlying c-client library also supports NNTP, POP3 and local mailbox access methods.
Requirements
This extension requires the c-client library to be installed. Grab the latest version from ftp://ftp.cac.washington.edu/imap/ and compile it.
It's important that you do not copy the IMAP source files directly into the system include directory as there may be conflicts. Instead, create a new directory inside the system include directory, such as /usr/local/imap-2000b/ (location and name depend on your setup and IMAP version), and inside this new directory create additional directories named lib/ and include/. From the c-client directory from your IMAP source tree, copy all the *.h files into include/ and all the *.c files into lib/. Additionally when you compiled IMAP, a file named c-client-a was created. Also put this in the lib/ directory but rename it as libc-client.a.
Note: To build the c-client library with SSL or/and Kerberos support read the docs supplied with the package.
Installation
To get these functions to work, you have to compile PHP with --with-imap[=DIR], where DIR is the c-client install prefix. From our example above, you would use --with-imap=/usr/local/imap-2000b. This location depends on where you created this directory according to the description above. Windows users may include the php_imap.dll DLL in php.ini
Note: Depending how the c-client was configured, you might also need to add --with-imap-ssl=/path/to/openssl/ and/or --with-kerberos=/path/to/kerberos into the PHP configure line.
Predefined Constants
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
- NIL (integer)
- OP_DEBUG (integer)
- OP_READONLY (integer)
- OP_ANONYMOUS (integer)
- OP_SHORTCACHE (integer)
- OP_SILENT (integer)
- OP_PROTOTYPE (integer)
- OP_HALFOPEN (integer)
- OP_EXPUNGE (integer)
- OP_SECURE (integer)
- CL_EXPUNGE (integer)
- FT_UID (integer)
- FT_PEEK (integer)
- FT_NOT (integer)
- FT_INTERNAL (integer)
- FT_PREFETCHTEXT (integer)
- ST_UID (integer)
- ST_SILENT (integer)
- ST_SET (integer)
- CP_UID (integer)
- CP_MOVE (integer)
- SE_UID (integer)
- SE_FREE (integer)
- SE_NOPREFETCH (integer)
- SO_FREE (integer)
- SO_NOSERVER (integer)
- SA_MESSAGES (integer)
- SA_RECENT (integer)
- SA_UNSEEN (integer)
- SA_UIDNEXT (integer)
- SA_UIDVALIDITY (integer)
- SA_ALL (integer)
- LATT_NOINFERIORS (integer)
- LATT_NOSELECT (integer)
- LATT_MARKED (integer)
- LATT_UNMARKED (integer)
- SORTDATE (integer)
- SORTARRIVAL (integer)
- SORTFROM (integer)
- SORTSUBJECT (integer)
- SORTTO (integer)
- SORTCC (integer)
- SORTSIZE (integer)
- TYPETEXT (integer)
- TYPEMULTIPART (integer)
- TYPEMESSAGE (integer)
- TYPEAPPLICATION (integer)
- TYPEAUDIO (integer)
- TYPEIMAGE (integer)
- TYPEVIDEO (integer)
- TYPEOTHER (integer)
- ENC7BIT (integer)
- ENC8BIT (integer)
- ENCBINARY (integer)
- ENCBASE64 (integer)
- ENCQUOTEDPRINTABLE (integer)
- ENCOTHER (integer)
See Also
This document can't go into detail on all the topics touched by the provided functions. Further information is provided by the documentation of the c-client library source (docs/internal.txt). and the following RFC documents:
RFC2821: Simple Mail Transfer Protocol (SMTP).
RFC2822: Standard for ARPA internet text messages.
RFC2060: Internet Message Access Protocol (IMAP) Version 4rev1.
RFC1939: Post Office Protocol Version 3 (POP3).
RFC977: Network News Transfer Protocol (NNTP).
RFC2076: Common Internet Message Headers.
RFC2045 , RFC2046 , RFC2047 , RFC2048 & RFC2049: Multipurpose Internet Mail Extensions (MIME).
- Table of Contents
- imap_8bit -- Convert an 8bit string to a quoted-printable string
- imap_alerts -- This function returns all IMAP alert messages (if any) that have occurred during this page request or since the alert stack was reset
- imap_append -- Append a string message to a specified mailbox
- imap_base64 -- Decode BASE64 encoded text
- imap_binary -- Convert an 8bit string to a base64 string
- imap_body -- Read the message body
- imap_bodystruct -- Read the structure of a specified body section of a specific message
- imap_check -- Check current mailbox
- imap_clearflag_full -- Clears flags on messages
- imap_close -- Close an IMAP stream
- imap_createmailbox -- Create a new mailbox
- imap_delete -- Mark a message for deletion from current mailbox
- imap_deletemailbox -- Delete a mailbox
- imap_errors -- This function returns all of the IMAP errors (if any) that have occurred during this page request or since the error stack was reset.
- imap_expunge -- Delete all messages marked for deletion
- imap_fetch_overview -- Read an overview of the information in the headers of the given message
- imap_fetchbody -- Fetch a particular section of the body of the message
- imap_fetchheader -- Returns header for a message
- imap_fetchstructure -- Read the structure of a particular message
- imap_get_quota -- Retrieve the quota level settings, and usage statics per mailbox
- imap_get_quotaroot -- Retrieve the quota settings per user
- imap_getmailboxes -- Read the list of mailboxes, returning detailed information on each one
- imap_getsubscribed -- List all the subscribed mailboxes
- imap_header -- Alias of imap_headerinfo()
- imap_headerinfo -- Read the header of the message
- imap_headers -- Returns headers for all messages in a mailbox
- imap_last_error -- This function returns the last IMAP error (if any) that occurred during this page request
- imap_list -- Read the list of mailboxes
- imap_listmailbox -- Alias of imap_list()
- imap_listscan -- Read the list of mailboxes, takes a string to search for in the text of the mailbox
- imap_listsubscribed -- Alias of imap_lsub()
- imap_lsub -- List all the subscribed mailboxes
- imap_mail_compose -- Create a MIME message based on given envelope and body sections
- imap_mail_copy -- Copy specified messages to a mailbox
- imap_mail_move -- Move specified messages to a mailbox
- imap_mail -- Send an email message
- imap_mailboxmsginfo -- Get information about the current mailbox
- imap_mime_header_decode -- Decode MIME header elements
- imap_msgno -- This function returns the message sequence number for the given UID
- imap_num_msg -- Gives the number of messages in the current mailbox
- imap_num_recent -- Gives the number of recent messages in current mailbox
- imap_open -- Open an IMAP stream to a mailbox
- imap_ping -- Check if the IMAP stream is still active
- imap_qprint -- Convert a quoted-printable string to an 8 bit string
- imap_renamemailbox -- Rename an old mailbox to new mailbox
- imap_reopen -- Reopen IMAP stream to new mailbox
- imap_rfc822_parse_adrlist -- Parses an address string
- imap_rfc822_parse_headers -- Parse mail headers from a string
- imap_rfc822_write_address -- Returns a properly formatted email address given the mailbox, host, and personal info.
- imap_scanmailbox -- Alias of imap_listscan()
- imap_search -- This function returns an array of messages matching the given search criteria
- imap_set_quota -- Sets a quota for a given mailbox
- imap_setacl -- Sets the ACL for a giving mailbox
- imap_setflag_full -- Sets flags on messages
- imap_sort -- Sort an array of message headers
- imap_status -- This function returns status information on a mailbox other than the current one
- imap_subscribe -- Subscribe to a mailbox
- imap_thread -- Return threaded by REFERENCES tree
- imap_uid -- This function returns the UID for the given message sequence number
- imap_undelete -- Unmark the message which is marked deleted
- imap_unsubscribe -- Unsubscribe from a mailbox
- imap_utf7_decode -- Decodes a modified UTF-7 encoded string.
- imap_utf7_encode -- Converts ISO-8859-1 string to modified UTF-7 text.
- imap_utf8 -- Converts MIME-encoded text to UTF-8