The command used to retrieve these basic mailbox statistics is STAT.
A possible server response would be +OK 18 67042. In this case it does matter what follows the +OK sign. Immediately following is the number of messages in the mailbox, then, separated by a whitespace, comes the size of the mailbox in octets (an octet are 8 bits).
STAT
+OK 18 67042
If there is no mail, the server responds with +OK 0 0. Since there are 18 new messages on the server, however, we can list these using the LIST command. In response, the server lists the messages in the following format:
LIST
+OK 18 messages (67042 octets)
1 2552
2 3297
...
18 3270
.
The messages are listed one at a time, each followed by its size in octets. The list ends with a period on a line by itself.
The LIST command can take the number of a message as an optional argument, LIST 2 for example. The server's response to this request would be +OK 2 3297, the message number followed by the size of the message. If you try to list a message that does not exist, like LIST 23, the server shows no imagination and says: -ERR no such message.
Now that we know how many messages are in our account and how big they are, it's finally time to retrieve them so we can read them too.

