The implementation supports most of the commands specified in:
- {@link http://www.faqs.org/rfcs/rfc1730.html} (IMAP4)
- {@link http://www.faqs.org/rfcs/rfc2060.html} (IMAP4rev1)
Each user account on the IMAP server has it's own folders (mailboxes).
Mailboxes can be created, renamed or deleted. All accounts have a special
mailbox called Inbox which cannot be deleted or renamed.
Messages are organized in mailboxes, and are identified by a message number
(which can change over time) and a unique ID (which does not change under
normal circumstances). The commands operating on messages can handle both
modes (message numbers or unique IDs).
Messages are marked by certain flags (SEEN, DRAFT, etc). Deleting a message
actually sets it's DELETED flag, and a later call to {@link expunge()} will
delete all the messages marked with the DELETED flag.
The IMAP server can be in different states. Most IMAP commands require
that a connection is established and a user is authenticated. Certain
commands require in addition that a mailbox is selected.
The IMAP transport class allows developers to interface with an IMAP server.
The commands which support unique IDs to refer to messages are marked with
[*] (see {@link ezcMailImapTransportOptions} to find out how to enable
unique IDs referencing):
Basic commands:
- connect to an IMAP server ({@link __construct()})
- authenticate a user with a username and password ({@link authenticate()})
- select a mailbox ({@link selectMailbox()})
- disconnect from the IMAP server ({@link disconnect()})
Work with mailboxes:
- get the list of mailboxes of the user ({@link listMailboxes()})
- create a mailbox ({@link createMailbox()})
- rename a mailbox ({@link renameMailbox()})
- delete a mailbox ({@link deleteMailbox()})
- append a message to a mailbox ({@link append()})
- select a mailbox ({@link selectMailbox()})
- get the status of messages in the current mailbox ({@link status()})
- get the number of messages with a certain flag ({@link countByFlag()})
Work with message numbers (on the currently selected mailbox):
- get the message numbers and sizes of all the messages ({@link listMessages()})
- get the message numbers and IDs of all the messages ({@link listUniqueIdentifiers()})
- [*] get the headers of a certain message ({@link top()})
- [*] delete a message ({@link delete()} and {@link expunge()})
- [*] copy messages to another mailbox ({@link copyMessages()})
- [*] get the sizes of the specified messages ({@link fetchSizes()})
Work with flags (on the currently selected mailbox):
- [*] get the flags of the specified messages ({@link fetchFlags()})
- [*] set a flag on the specified messages ({@link setFlag()})
- [*] clear a flag from the specified messages ({@link clearFlag()})
Work with {@link ezcMailImapSet} sets (parseable with {@link ezcMailParser})
(on the currently selected mailbox):
- [*] create a set from all messages ({@link fetchAll()})
- [*] create a set from a certain message ({@link fetchByMessageNr()})
- [*] create a set from a range of messages ({@link fetchFromOffset()})
- [*] create a set from messages with a certain flag ({@link fetchByFlag()})
- [*] create a set from a sorted range of messages ({@link sortFromOffset()})
- [*] create a set from a sorted list of messages ({@link sortMessages()})
- [*] create a set from a free-form search ({@link searchMailbox()})
Miscellaneous commands:
- get the capabilities of the IMAP server ({@link capability()})
- get the hierarchy delimiter (useful for nested mailboxes) ({@link getHierarchyDelimiter()})
- issue a NOOP command to keep the connection alive ({@link noop()})
The usual operation with an IMAP server is illustrated by this example:
create a new IMAP transport object by specifying the server name, optional port
and optional SSL mode
$options = new ezcMailImapTransportOptions();
$options->ssl = true;
$imap = new ezcMailImapTransport( 'imap.example.com', null, $options );
Authenticate to the IMAP server
$imap->authenticate( 'username', 'password' );
Select a mailbox (here 'Inbox')
$imap->selectMailbox( 'Inbox' );
issue commands to the IMAP server
for example get the number of RECENT messages
$recent = $imap->countByFlag( 'RECENT' );
see the above list of commands or consult the online documentation for
the full list of commands you can issue to an IMAP server and examples
disconnect from the IMAP server
$imap->disconnect();
See {@link ezcMailImapTransportOptions} for other options you can specify
for IMAP.