What is the use of Subscribe and Unsubscribe commands in Imap4req1? I checked RFC 3501, but i could not understand its use. What will happen when i write following commands
A SUBSCRIBE "MAILBOX_NAME"
A UNSUBSCRIBE "MAILBOX_NAME"
will server treat those mailboxes as separate one?
Sample :
please check below once, and tell the difference
A LIST "" "*"
* LIST (\HasNoChildren) "/" "Bulk Mail"
* LIST (\HasNoChildren) "/" "Draft"
* LIST (\HasNoChildren) "/" "Inbox"
* LIST (\HasNoChildren) "/" "Sent"
* LIST (\HasNoChildren) "/" "Trash"
A OK LIST completed
A SUBSCRIBE INBOX
A OK SUBSCRIBE completed
A LSUB "" "*"
* LSUB (\HasNoChildren) "/" "Bulk Mail"
* LSUB (\HasNoChildren) "/" "Draft"
* LSUB (\HasNoChildren) "/" "Inbox"
* LSUB (\HasNoChildren) "/" "Sent"
* LSUB (\HasNoChildren) "/" "Trash"
A OK LSUB completed
They change the output of the LSUB
command. That's it. SUBSCRIBE
adds folders to the output of the LSUB
command. UNSUBSCRIBE
will remove them from the output of the LSUB
command. That is, LSUB
shows only subscribed folders.
LIST
will always show all folders.
For example starting with all folders subscribed:
a LIST "" *
* LIST (\HasNoChildren) "." "INBOX.Drafts"
* LIST (\HasNoChildren) "." "INBOX.Sent"
* LIST (\HasNoChildren) "." "INBOX.Trash"
* LIST (\Marked \HasChildren) "." "INBOX"
a OK LIST completed
a LSUB "" *
* LSUB (\Marked \HasChildren) "." "INBOX"
* LSUB (\HasNoChildren) "." "INBOX.Drafts"
* LSUB (\HasNoChildren) "." "INBOX.Sent"
* LSUB (\HasNoChildren) "." "INBOX.Trash"
a OK LSUB completed
Now let's unsubscribe INBOX.Sent
:
a UNSUBSCRIBE INBOX.Sent
a OK Folder unsubscribed.
a LSUB "" *
* LSUB (\Marked \HasChildren) "." "INBOX"
* LSUB (\HasNoChildren) "." "INBOX.Drafts"
* LSUB (\HasNoChildren) "." "INBOX.Trash"
a OK LSUB completed
All that's different is that INBOX.Sent
has been removed from the LSUB output. Note that LIST output will not have been affected at all.
Now let's put it back:
a SUBSCRIBE INBOX.Sent
a OK Folder subscribed.
a LSUB "" *
* LSUB (\HasNoChildren) "." "INBOX.Sent"
* LSUB (\Marked \HasChildren) "." "INBOX"
* LSUB (\HasNoChildren) "." "INBOX.Drafts"
* LSUB (\HasNoChildren) "." "INBOX.Trash"
a OK LSUB completed
They are generally used for a client to mark folders the user is interested in seeing.