Archive for the ‘Protocol’ Category

Unique ID in POP3 protocol

Wednesday, January 5th, 2011

RFC 1939 specification says:

“The unique-id of a message is an arbitrary server-determined string, [...], which uniquely identifies a message within a maildrop and which persists across sessions.”

“The server should never reuse an unique-id in a given maildrop, for as long as the entity using the unique-id exists.”

So in theory if the email is deleted server may reuse the same unique-id.

“While it is generally preferable for server implementations to store arbitrarily assigned unique-ids in the maildrop, this specification is intended to permit unique-ids to be calculated as a hash of the message.

Clients should be able to handle a situation where two identical copies of a message in a maildrop have the same unique-id.”

Mail.dll will not throw exception in such case, but please note that as internally Mail.dll uses dictionaries to store unique-ids, Pop3.GetAll() method will not return duplicates.

Unique ID in IMAP protocol

Wednesday, January 5th, 2011

RFC 3501 specification says:

“2.3.1.1. Unique Identifier (UID) Message Attribute

A 32-bit value assigned to each message, which when used with the unique identifier validity value (see below) forms a 64-bit value that MUST NOT refer to any other message in the mailbox (folder) or any subsequent mailbox (folder) with the same name forever.”

“The unique identifier of a message MUST NOT change during the session, and SHOULD NOT change between sessions.”

“Any change of unique identifiers between sessions MUST be detectable using the UIDVALIDITY mechanism”

“The unique identifier validity value is sent in a UIDVALIDITY response code in an OK untagged response at mailbox (folder) selection time.”

Any change of unique identifiers between session causes the change of FolderStatus.UIDValidity:

using(Imap client = new Imap())
{
    client.Connect("imap.example.org");
    FolderStatus folderStatus = client.Select("Inbox");
    Console.WriteLine(
        "Folder UIDValidity: " + folderStatus.UIDValidity);
    client.Close();
}
Using client As New Imap()
    client.Connect("imap.example.org")
    Dim folderStatus As FolderStatus = client.Select("Inbox")
    Console.WriteLine( _
        "Folder UIDValidity: " + folderStatus.UIDValidity)
    client.Close()
End Using

Uniqueness

Unfortunately: “There is no assurance that the UIDVALIDITY values of two mailboxes (folders) be different, so the UIDVALIDITY in no way identifies a mailbox (folder).”

This means that:

  • UID of the email may be not unique on the server (2 messages in different folders may have same UID)
  • FolderStatus.UIDValidity + UID may be not unique on the server (2 folders may have same UIDValidity)

UIDs across sessions

  • UIDs are ‘supposed’ to be stable across sessions, and never change, and always increase in value.
  • You need to check the FolderStatus.UIDValidity when you select the folder. If the FolderStatus.UIDValidity number hasn’t changed, then the UIDs are still valid across sessions.

POP3 vs IMAP

Thursday, August 5th, 2010

POP3 and IMAP are application-layer Internet standard protocols used by local e-mail clients to retrieve e-mails from a remote server over a TCP/IP connection. Virtually all modern e-mail clients and mail servers support both protocols as a means of transferring e-mail messages from a server.

They are both text-based. Both transmit more or less same amount of data.

Here is the brief comparison of both:

POP3 IMAP
Intended message store Client Server
Download message YES YES
Download message headers YES YES
Download detailed email information NO YES
Download specific message part (single attachment) NO YES
Delete message YES YES
Send message NO (use SMTP) NO (use SMTP)
Get only unseen messages NO YES
Mark message Seen/Unseen NO YES
Server side search NO YES
Folders NO YES
Sent items NO YES
SSL YES YES
Push email NO YES

Mail.dll supports both POP3 and IMAP (and SMTP), give it a try at:
http://www.limilabs.com/mail