Search code examples
jakarta-mailimap

Does an IMAP store always have an INBOX?


I'm using JavaMail's IMAP Store.

When opening the inbox, is it safe to assume that the name is always called "INBOX"?

IMAPFolder folder = (IMAPFolder) store.getFolder("INBOX");

Or is the "inbox" name nothing special and on a Swedish IMAP server it could be called "inkorg"?

I guess this same question applies equally to IMAP in general, beyond JavaMail.


Solution

  • Yes. Additionally, according to RFC 3501: INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1, INBOX has a number of special behaviors to boot:

    5.1. Mailbox Naming

    The case-insensitive mailbox name INBOX is a special name reserved to mean "the primary mailbox for this user on this server". The interpretation of all other names is implementation-dependent.

    6.3.3. CREATE Command

    It is an error to attempt to create INBOX or a mailbox with a name that refers to an extant mailbox.

    6.3.4. DELETE Command

    It is an error to attempt to delete INBOX or a mailbox name that does not exist.

    6.3.5. RENAME Command

    Renaming INBOX is permitted, and has special behavior. It moves all messages in INBOX to a new mailbox with the given name, leaving INBOX empty. If the server implementation supports inferior hierarchical names of INBOX, these are unaffected by a rename of INBOX.