Search code examples
gmailimapgmail-imap

Gmail IMAP: Is there a way to get which mailbox is currently selected?


Are there any IMAP command or IMAP response code for Gmail IMAP, which can tell what is currently selected mailbox?

We need this for debugging purposes and optimization.

EDIT: Why? We believe that 3rd-party library we are using will sometime not send "SELECT" command to IMAP server. So we need a way to verify what IMAP server things it is selected mailbox.


Solution

  • There's no IMAP command to get this information.

    The best I can come up with is having a message in each mailbox saying which mailbox it is in and then you could grab the content of the messages to verify which mailbox is currently selected.