imap4 agreement

Turn to  http://bambooice.blog.hexun.com/33960499_d.html

IMAP4 protocol processing status and workflow
one any time, each IMAP4 service processing threads are in a state of four treatments. Most IMAP4 command will only be effective under certain processing status. If the IMAP4 client software attempts to send commands without a proper state, the server returns a failure message protocol error, such as BAD or NO and the like.


Non-certified status
in this state, the client software must issue an authentication request command. When IMAP4 connection is established, the server processing threads automatically enters this state.
Certification status
in the state certification, client software must select a mailbox. This state is confirmed in the authentication request command to enter a reply, or directly into the pre-authentication after the connection is established.
The state has chosen
this status indicates IMAP4 client software has selected a Folder. You can send commands to retrieve all message content in this state.
Offline
In this state, the connection has been terminated, the server will close the connection. The client software can issue commands by the server or forced into this state.

IMAP Command Summary
IMAP and POP3 protocol commands the biggest difference is a former Each command has a label specified by the Client, the same session, each Client issued the command will have a different label; and for each Server Client command must be issued as a response to the same label. This makes the IMAP session Client may send multiple commands at the same time, while the Server is completely concurrent processing these commands, without waiting for a command is complete before processing the next.

The following are several commonly used IMAP commands
the LOGIN   US ername password
the LOGIN command log IMAP server, and POP3 are significantly different user name and password at the same time as a parameter submitted to the Server, POP3 complete the same operation needs two commands USER and PASS. 
C: a001 LOGIN SMITH SESAME
S: a001 OK LOGIN completed

The CREATE   Folder
the CREATE can create to specify the name of the folder. The folder name is usually a file with a path to the folder full name.
C: A003 owatagusiam the CREATE /
S: A003 the CREATE Completed the OK
C: A004 owatagusiam the CREATE / blurdybloop
S: A004 the CREATE Completed the OK

Folder DELETE
DELETE command to delete the specified folder name. The folder name is usually a file with a path to the folder full name.
C: A683 blurdybloop the DELETE
S: A683 Completed the DELETE the OK 
C: A684 the DELETE foo
S: A684 NO Hierarchical names the Name foo has the inferior
C: A685 the DELETE foo / bar 
S: A685 the DELETE the Completed the OK

Old new new Folder Folder RENAME
RENAME command to change the name of the folder.
C: A683 sarasoop the RENAME blurdybloop
S: A683 Completed the RENAME the OK
C: A684 Zowie the RENAME foo
S: A684 the RENAME the Completed the OK

BASE Template the LIST
the LIST command lists the existing mailbox folder, a bit like operating system directory listing command. This command can include characteristics of the starting position of the path and file folder needs listed conforms with wildcards, *.
C: A101 the LIST
S: * the LIST (/ Noselect)
S: A101 the OK the Completed the LIST
C: A102 # news.comp.mail.misc the LIST
S: * the LIST (/ Noselect) #news.
S: A102 the OK the Completed the LIST
C: A103 the LIST / usr / Staff / Jones
S: * the LIST (/ Noselect) /
S: A103 the OK the LIST the Completed
C: A202 the LIST ~ / Mail /%
S: * the LIST (/ Noselect) ~ / Mail / foo
S: * the LIST () ~ / Mail / Meetings
S: A202 the LIST Completed the OK

Folder size mail Data Attributes the APPEND
the APPEND command allows a message to the specified carrier in the Folder Client. Command contains a new message attributes, size, followed by the message data.
C: A003-the APPEND saved messages (/ Seen) {310}
C: a Date: Mon,. 7 On Feb 1994 21:52:25 -0800 (the PST)
C: the From: Fred Foobar & lt; [In Email] [email protected] [ / In Email] & gt;
C: the Subject: Meeting afternoon
C: the To: [In Email] [email protected] [/ In Email]
C: the Message-Id: & lt; [In Email] [email protected] [/ In Email ] & gt;
C: MIME-Version: 1.0
C: Content-Type: TEXT / PLAIN; CHARSET = US-ASCII
C:
? C: the Hello Joe, do you of Think WE CAN AT 3:30 Meet Tomorrow
C:
S: A003 the OK APPEND completed

Folder the SELECT
the SELECT command so that a selected Client Folder, represent about to make that message in the Folder.
C: A142 the SELECT INBOX
S: * 172 EXISTS
S: *. 1 the RECENT
S: * the OK [UNSEEN 12 is] the Message 12 is IS First Unseen
S: * the OK [UIDVALIDITY 3,857,529,045] UIDs Valid
S: * the FLAGS (/. Answered / Flagged / Deleted / Seen / Draft)
S: * the OK [PERMANENTFLAGS (/ Deleted / Seen / *)] Limited
S: A142 the OK [the READ-the WRITE] Completed the SELECT

... FETCH
FETCH command IMAP protocol is the most complex commands. FETCH command many parameters are complex, numerous to list, but the essential feature is to allow the dismantling of the message according to MIME structure member fragmentary extracted. For example, the extraction may be utilized FETCH command message header, one attachment, attachment of a field or a message header, and the like.

The Attributes new new mail the above mentioned id STORE
STORE command is used to modify the specified message properties, including e-mail marked to read tags, remove the tag, and so on.
C: A003 the STORE 2:. 4 + the FLAGS (/ Deleted)
S: * 2 the FETCH the FLAGS (/ Deleted / Seen)
S: *. 3 the FETCH the FLAGS (/ Deleted)
S: *. 4 the FETCH the FLAGS (/ Deleted / Flagged / Seen)
S : A003 OK STORE completed

CLOSE
CLOSE command indicates the end of access to the current Client Folder, and then you can SELECT another Folder.
C: A341 the CLOSE
S: A341 Completed the CLOSE the OK

EXPUNGE
EXPUNGE hit the mailbox all messages marked for deletion completely removed. EXPUNGE deleted messages will not be restored. 
C: A202 the EXPUNGE
S: the EXPUNGE. 3 *
S: the EXPUNGE. 3 *
S: the EXPUNGE. 5 *
S: the EXPUNGE. 8 *
S: the EXPUNGE Completed the OK A202

LOGOUT
LOGOUT命令结束本次IMAP会话。
C: A023 LOGOUT
S: * BYE IMAP4rev1 Server logging out
S: A023 OK LOGOUT completed
(Server and client then close the connection)


IMAP4会话实例
S: * OK IMAP4rev1 Service Ready
C: a001 login mrc secret
S: a001 OK LOGIN completed
C: a002 select inbox
S: * 18 EXISTS
S: * FLAGS (/Answered /Flagged /Deleted /Seen /Draft)
S: * 2 RECENT
S: * OK [UNSEEN 17] Message 17 is the first unseen message
S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: a002 OK [READ-WRITE] SELECT completed
C: a003 fetch 12 full
S: * 12 FETCH (FLAGS (/Seen) INTERNALDATE 17-Jul-1996 02:44:25 -0700
RFC822.SIZE 4286 ENVELOPE (Wed, 17 Jul 1996 02:23:25 -0700 (PDT) IMAP4rev1 WG mtg summary and minutes
((Terry Gray NIL  gray cac.washington.edu)) 
((Terry Gray NIL  gray cac.washington.edu)) 
((Terry Gray NIL  gray cac.washington.edu)) 
((NIL NIL imapcac.washington.edu)) 
((NIL NIL minutes CNRI.Reston.VA.US) 
(John Klensin NIL KLENSIN INFOODS.MIT.EDU)) NIL NIL [email][email protected][/email]) 
BODY (TEXT PLAIN (CHARSET US-ASCII) NIL NIL 7BIT 3028 92)) 
S: a003 OK FETCH completed
C: a004 fetch 12 body[header]
S: * 12 FETCH (BODY[HEADER] {350}
S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT)
S: From: Terry Gray <[email][email protected][/email]>
S: Subject: IMAP4rev1 WG mtg summary and minutes
S: To: [email][email protected][/email]
S: cc: [email][email protected][/email], John Klensin <[email][email protected][/email]>
S: Message-Id: <[email][email protected][/email]>
S: MIME-Version: 1.0
S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
S:
S: )
S: a004 OK FETCH completed
C: a005 store 12 +flags /deleted
S: * 12 FETCH (FLAGS (/Seen /Deleted))
S: a005 OK +FLAGS completed
C: a006 logout
S: * BYE IMAP4rev1 server terminating connection
S: a006 OK LOGOUT completed

Guess you like

Origin blog.csdn.net/soliy/article/details/5459605