PowerTCP Mail for .NET
IMAP4 Protocol
Send comments on this topic.



Glossary Item Box

Imap4 Described

IMAP4 (Internet Message Access Protocol) allows remote manipulation of messages on the server as if they were on the local machine. IMAP was implemented in response to the shortcomings of POP, most notably the lack of sophisticated mail manipulation on the server and the inability to access mail from more than one computer.

The message manipulation described above occurs through commands issued by the client and responses issued by the server. Every command issued by the client must be preceded by a unique, client-defined identifier (for example, A0001), which must increment with each successive command. These commands allow a client to create and manipulate folders called "mailboxes" on the server in a way that is functionally equivalent to manipulating local folders. The commands also give the client the ability to "resynchronize" the server. As commands are issued an IMAP4 session progresses through four states: non-authenticated, authenticated, selected, and logout.


IMAP4 Non-Authenticated State

A client makes a TCP connection with the server on port 143, at which point the session enters the non-authenticated state. In this state the client has access to four commands: CAPABILITY (displays special capabilities of the server), NOOP (causes the server to give a positive response), LOGIN (authenticates the client), and LOGOUT (ends the session). In order for the session to continue, the client must supply authentication credentials with the LOGIN command. Once proper credentials have been supplied, the session moves into the authenticated state.


IMAP4 Authenticated State

Once in the authenticated state, the client must select a valid mailbox before the session is able to progress to the next state. This selection is accomplished by use of either the SELECT or the EXAMINE command followed by a valid mailbox name. The only difference between these commands is that when using SELECT, the mailbox is opened with read/write privileges, whereas EXAMINE opens the mailbox with read-only privileges. Once one of these commands is executed successfully, the session moves into the selected state. In the authenticated state, the client has access to all commands from the non-authenticated state (except for LOGIN). The client can also CREATE a mailbox, get the STATUS of a mailbox, RENAME a mailbox, and perform other commands involving the manipulation of mailboxes.


IMAP4 Selected State

The selected state is the state in which the actual message access happens. The client can issue any of the commands from the authenticated state, as well as CLOSE (closes the mailbox and returns to authenticated state), EXPUNGE (removes all messages flagged for deletion), SEARCH (allows the client to find messages using certain criteria), FETCH (returns all or a part of a message), STORE (allows updating of flags stored with each message), COPY (allows copying of a message set to a mailbox). From the selected state, the client can issue the CLOSE command to return to the authenticated state or LOGOUT to cause the server to go to the logout state.


IMAP4 Logout State

In the logout state the server simply terminates the connection.


The graphic below illustrates this progression through the four states.



IMAP4 Sample Dialog

The following example demonstrates a dialog that could occur between a client downloading messages from a server using the IMAP protocol.

< connection >

Client: A0001 LOGIN username password

Server: A0001 OK LOGIN completed

Client: A0002 CREATE mailbox1

Server: A0002 OK CREATE completed

Client: A0003 SELECT mailbox1

Server: A0003 OK SELECT completed

< note: since this is a newly created mailbox, no mail exists >

Client: A0004 FETCH 1:3

Server: A0004 BAD FETCH

Client: A0005 Quit

Server: A0005 OK QUIT completed

< connection closed >

 

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.