Number of Messages in a POP3 Inbox

There is often confusion about the number of messages in a POP3 inbox (for a given user account). Here are the typical scenarios that cause confusion:

  1. If your email client such as Outlook or Mozilla Thunderbird seem to show more messages than what Chilkat can see, then make sure you realize which messages are stored locally by Outlook, and which messages are actually on the POP3 server.  The intention of the POP3 protocol is that messages will be downloaded and removed from the server and managed locally.  (The intention of the IMAP protocol is the opposite: Messages are generally kept on the server and managed there.)  This basic difference in semantics is the reason why the POP3 protocol is so much simpler (i.e. bare-bones functionality) as opposed to the much more complex IMAP protocol.
  2. If viewing emails in a web-based email client such as GMail, also be careful about which emails are *actually* in the POP3 inbox vs. what emails have been removed from the inbox and are managed by the webapp (i.e. GMail) on it’s server.  (Similar to Outlook and it’s local store.)
  3. Many mail servers provide both POP3 and IMAP interfaces.  The POP3 interface only has access to the  INBOX.  A POP3 client will not be able to see the other  IMAP mailboxes.
  4. Your POP3 session has access to only those emails that existed at the start of the POP3 session.  If more emails arrive during the session, a POP3 client must end the session (typically disconnect) and re-start a new session to see the new emails.

How to Verify Exactly how many Emails are in the POP3 Inbox

A POP3 server responds to the “STAT” command with a one-line response indicating the number of messages in the INBOX, and the  total byte count of all messages combined.   To see this information, start a POP3 session by calling the mailman.Pop3BeginSession.  Then call mailman.GetMailboxCount to return the number of messages.  It will return the exact number of messages that existed in the POP3 mailbox at the time the session was started.  You can examine the mailman.Pop3SessionLog property to see the STAT command and the raw response.  For example:

**** Connected to
< +OK Welcome to MailEnable POP3 Server <576.1827327234@xxxxxxxxxxxx>
> USER ****
< +OK
> PASS ****
< +OK
< +OK 54 2260671

Here we see that the INBOX contains 54 messages, and the sum size in bytes of all the messages is 2260671.

In addition, a POP3 server responds to the UIDL command with the full list of UIDL’s (one per line) for all the emails in the INBOX.  You may call mailman.GetUidls to get the full set of UIDL’s. The number of UIDL’s should match the number returned by GetMailboxCount.

If you examine the Pop3SessionLog after calling GetUidls, you’ll see something like this:

< +OK
< 1 2608A7A521EA454FB4B5FE790982286B
2 680602D898AF4946B73570C9C4B3512B
3 6982607A73C24948AC9781254ABC8797
52 F85CBF78337443D6BD7EF16D9B1609BD
53 3AB8CBEFF6B648A08C274F312FF1AB77
54 B06EFE3B1890462BAD391301F9109278