Skip to content

Latest commit

 

History

History
39 lines (34 loc) · 1.52 KB

File metadata and controls

39 lines (34 loc) · 1.52 KB

Mailbox roles

Each mailbox (inbox, drafts, spam, archive, etc.) may have a role and a name (and other attributes).

Note, you should always use the role attribute, as names may be localised (or even different between different servers with the same language)!

JMAP Client Guide

Many roles are possible. Here are some of the most common roles used by JMAP: all, archive, drafts, flagged, important, inbox, junk, scheduled, sent, snoozed, subscribed, trash. Custom mailboxes seem to never have a role; their role attribute has a value of null. I created the list of roles by combining IMAP Mailbox Name Attributes with the output of the code below.

func getMailboxRoles(accountId, url, token string) {
	reqBody := fmt.Sprintf(`
		{
			"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
			"methodCalls": [
				[
					"Mailbox/get",
					{
						"accountId": "%s",
						"properties": ["id", "role", "name"]
					},
					"0"
				]
			]
		}
	`, accountId)
	res, err := makeJmapCall("POST", url, token, reqBody)
	if err != nil {
		panic(err)
	}
	resBytes, err := io.ReadAll(res.Body)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(resBytes))
}