Skip to content

Instantly share code, notes, and snippets.

@nevans
Last active November 28, 2023 12:48
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nevans/8ef449da0786f9d1cc7c8324a288dd9b to your computer and use it in GitHub Desktop.
Save nevans/8ef449da0786f9d1cc7c8324a288dd9b to your computer and use it in GitHub Desktop.
IMAP Specifications

IMAP specifications

(TODO) All IANA registered IMAP capabilities, response codes, keywords, mailbox attributes, the most relevant SASL mechanisms, and other relevant specifications.

  • ⛔️: obsolete specifications that have been deprecated or replaced
  • ⏭️: extensions that have been completely or partially included in IMAP4rev2.
  • ✨: extensions that are recommended for IMAP4rev2 servers and clients. The IETF EXTRA WG decided that requiring them as a part of IMAP4rev2 would push the bar to implement too high for new implementations.
  • 🗑: extensions that have been completely or partially deprecated or removed in IMAP4rev2.
  • 🍋: extensions that are included in the "Lemonade" profile RFC5550. The Lemonade profile is not fully supported by the most common email servers nor by most email clients, but many of its included extensions are both widely deployed and very useful.
  • 🔑: related to authentication or authorization
Reference (year) Extension notes
RFC2060 (1997) ⛔️ IMAP4rev1 Replaced by RFC3501 (2003)
RFC2060 (1997) ⛔️ Resp Code: NEWNAME ⛔️ OBSOLETE (See RFC3501)
RFC2087 (1997) QUOTA Replaced by RFC9208 (2022)
RFC2088 (1997) ⛔️ LITERAL+ Replaced by RFC7888 (2016)
RFC2177 (1997) ⏭️🍋 IDLE
RFC2192 (1997) ⛔️ IMAP URL Scheme Replaced by RFC5092 (2007)
RFC2193 (1997) MAILBOX-REFERRALS
RFC2221 (1997) Resp Code: REFERRAL
RFC2221 (1997) 🔑 LOGIN-REFERRALS
RFC2342 (1998) ⏭️🍋 NAMESPACE
RFC2595 (1999) ⏭️🔑 LOGINDISABLED Included and required by RFC3501
RFC2595 (1999) ⏭️🔒 STARTTLS Included and required by RFC3501
RFC2971 (2000) ID
RFC3348 (2002) ⏭️ CHILDREN a subset of LIST-EXTENDED
RFC3501 (2003) ⏭️🗑 IMAP4rev1 Internet Message Access Protocol - VERSION 4rev1
RFC3501 (2003) ⏭️📬 Mbox Attr: \Marked 📬 Server has marked the mailbox as "interesting"
RFC3501 (2003) ⏭️📬 Mbox Attr: \NoInferiors 📬 No hierarchy under this name
RFC3501 (2003) ⏭️📬 Mbox Attr: \Noselect 📬 The mailbox is not selectable
RFC3501 (2003) ⏭️📬 Mbox Attr: \Unmarked 📬 No new messages since last select
RFC3501 (2003) ⏭️ Resp Code: ALERT
RFC3501 (2003) ⏭️ Resp Code: BADCHARSET
RFC3501 (2003) ⏭️ Resp Code: PARSE
RFC3501 (2003) ⏭️ Resp Code: PERMANENTFLAGS
RFC3501 (2003) ⏭️ Resp Code: READ-ONLY
RFC3501 (2003) ⏭️ Resp Code: READ-WRITE
RFC3501 (2003) ⏭️ Resp Code: TRYCREATE
RFC3501 (2003) ⏭️ Resp Code: UIDNEXT
RFC3501 (2003) ⏭️ Resp Code: UIDVALIDITY
RFC3501 (2003) 🗑 Resp Code: UNSEEN
RFC3501 (2003) ⏭️🔑 AUTH=* mechanisms are defined by SASL
RFC3501 (2003) 🗄️ IMAP Capabiliities Establishes IANA registry
RFC3501 (2003) 🗄️📬 Mailbox attributes Establishes IANA registry
RFC3501 Errata ⏭️ Updates to ABNF (charset, etc) 🌟 mostly included in RFC4466
RFC3502 (2003) MULTIAPPEND
RFC3503 (2003) ⏭️ Keyword: $MDNSent
RFC3516 (2003) ⏭️ Resp Code: UNKNOWN-CTE
RFC3516 (2003) ⏭️🍋 BINARY (rev2: FETCH part only)
RFC3691 (2004) ⏭️ UNSELECT
RFC4314 (2005) 🔑 ACL
RFC4314 (2005) 🔑 RIGHTS=
RFC4315 (2005) ⏭️ Resp Code: APPENDUID
RFC4315 (2005) ⏭️ Resp Code: COPYUID
RFC4315 (2005) ⏭️ Resp Code: UIDNOTSTICKY
RFC4315 (2005) ⏭️🍋 UIDPLUS
RFC4422 (2006) 🗄️🔑 SASL mechanisms Establishes IANA registry
RFC4466 (2006) ⏭️ 🌟 Collected ABNF extensions 🌟 Forward compatibility for parsing many extensions
RFC4467 (2006) Resp Code: URLMECH
RFC4467 (2006) 🔑🍋 URLAUTH
RFC4469 (2006) Resp Code: BADURL
RFC4469 (2006) Resp Code: TOOBIG
RFC4469 (2006) CATENATE Has errata which updates ABNF.
RFC4550 (2006) ⛔️ 🍋 The "Lemonade" Profile Replaced by RFC5550 (2009)
RFC4551 (2006) ⛔️🍋 Resp Code: HIGHESTMODSEQ Replaced by RFC7162 (2014)
RFC4551 (2006) ⛔️🍋 Resp Code: MODIFIED Replaced by RFC7162 (2014)
RFC4551 (2006) ⛔️🍋 Resp Code: NOMODSEQ Replaced by RFC7162 (2014)
RFC4551 (2006) ⛔️🍋 CONDSTORE Replaced by RFC7162 (2014)
RFC4616 (2006) ⏭️🔑 SASL: AUTH=PLAIN
RFC4731 (2006) ⏭️🍋 ESEARCH
RFC4959 (2007) ⏭️🔑 SASL-IR
RFC4978 (2007) 🍋 COMPRESS=DEFLATE 🌟 IMAP sessions can be significantly compressed.
RFC4978 (2007) 🍋 Resp Code: COMPRESSIONACTIVE
RFC5032 (2007) WITHIN
RFC5092 (2007) IMAP URL Scheme
RFC5161 (2008) ⏭️🍋 ENABLE
RFC5162 (2008) ⛔️🍋 Resp Code: CLOSED Replaced by RFC7162 (2014)
RFC5162 (2008) ⛔️🍋 QRESYNC Replaced by RFC7162 (2014)
RFC5182 (2008) Resp Code: NOTSAVED
RFC5182 (2008) ⏭️ SEARCHRES
RFC5255 (2008) Resp Code: BADCOMPARATOR
RFC5255 (2008) 🍋 I18NLEVEL=1
RFC5255 (2008) 🍋 I18NLEVEL=2
RFC5255 (2008) LANGUAGE
RFC5256 (2008) 🍋 SORT
RFC5256 (2008) THREAD
RFC5257 (2008) Resp Code: ANNOTATE
RFC5257 (2008) Resp Code: ANNOTATIONS
RFC5257 (2008) ANNOTATE-EXPERIMENT-1
RFC5258 (2008) ⏭️ LIST (RECURSIVEMATCH)
RFC5258 (2008) ⏭️ LIST (REMOTE)
RFC5258 (2008) ⏭️ LIST (SUBSCRIBED)
RFC5258 (2008) ⏭️ LIST RETURN (CHILDREN)
RFC5258 (2008) ⏭️ LIST RETURN (SUBSCRIBED)
RFC5258 (2008) ⏭️ LIST-EXTENDED resp CHILDINFO
RFC5258 (2008) 🗄️ LIST-EXTENDED registry Establishes IANA registry
RFC5258 (2008) ⏭️📬 Mbox Attr: \HasChildren 📬 Has accessible child mailboxes
RFC5258 (2008) ⏭️📬 Mbox Attr: \HasNoChildren 📬 Has no accessible child mailboxes
RFC5258 (2008) ⏭️📬 Mbox Attr: \NonExistent 📬 The mailbox name doesn't actually exist
RFC5258 (2008) ⏭️📬 Mbox Attr: \Remote 📬 The mailbox exists on a remote server
RFC5258 (2008) ⏭️📬 Mbox Attr: \Subscribed 📬 The mailbox is subscribed to
RFC5258 (2008) ⏭️ LIST-EXTENDED (rev2: everything except multiple mailbox patterns)
RFC5259 (2008) 🍋 Resp Code: MAXCONVERTMESSAGES
RFC5259 (2008) 🍋 Resp Code: MAXCONVERTPARTS
RFC5259 (2008) 🍋 Resp Code: TEMPFAIL
RFC5259 (2008) 🍋 CONVERT
RFC5267 (2008) 🍋 Resp Code: NOUPDATE
RFC5267 (2008) 🍋 CONTEXT=SEARCH
RFC5267 (2008) 🍋 CONTEXT=SORT
RFC5267 (2008) 🍋 ESORT
RFC5464 (2009) 🍋 Resp Code: METADATA
RFC5464 (2009) 🍋 METADATA-SERVER
RFC5464 (2009) 🍋 METADATA
RFC5465 (2009) 🍋 Resp Code: BADEVENT
RFC5465 (2009) 🍋 Resp Code: NOTIFICATIONOVERFLOW
RFC5465 (2009) 🍋 LIST-EXTENDED resp OLDNAME
RFC5465 (2009) 🍋 NOTIFY
RFC5466 (2009) 🍋 Resp Code: UNDEFINED-FILTER
RFC5466 (2009) 🍋 FILTERS
RFC5524 (2009) 🔑🍋 URLAUTH=BINARY
RFC5530 (2009) ⏭️ Resp Code: ALREADYEXISTS
RFC5530 (2009) ⏭️🔑 Resp Code: AUTHENTICATIONFAILED
RFC5530 (2009) ⏭️🔑 Resp Code: AUTHORIZATIONFAILED
RFC5530 (2009) ⏭️ Resp Code: CANNOT
RFC5530 (2009) ⏭️ Resp Code: CLIENTBUG
RFC5530 (2009) ⏭️ Resp Code: CONTACTADMIN
RFC5530 (2009) ⏭️ Resp Code: CORRUPTION
RFC5530 (2009) ⏭️ Resp Code: EXPIRED
RFC5530 (2009) ⏭️ Resp Code: EXPUNGEISSUED
RFC5530 (2009) ⏭️ Resp Code: INUSE
RFC5530 (2009) ⏭️ Resp Code: LIMIT
RFC5530 (2009) ⏭️ Resp Code: NONEXISTENT
RFC5530 (2009) ⏭️ Resp Code: NOPERM
RFC5530 (2009) ⏭️ Resp Code: OVERQUOTA
RFC5530 (2009) ⏭️ Resp Code: PRIVACYREQUIRED
RFC5530 (2009) ⏭️ Resp Code: SERVERBUG
RFC5530 (2009) ⏭️ Resp Code: UNAVAILABLE
RFC5530 (2009) 🗄️ Response codes registry Establishes an IANA registry
RFC5550 (2009) ⏭️🍋 Keyword: $Forwarded
RFC5550 (2009) 🍋 Keyword: $SubmitPending
RFC5550 (2009) 🍋 Keyword: $Submitted
RFC5550 (2009) 🍋 URL-PARTIAL
RFC5550 (2009) 🍋 🍋 The "Lemonade" Profile Profile "to Support Diverse Service Environments"
RFC5593 (2009) IMAP URL access identifier
RFC5598 (2009) ℹ️ Internet Mail Architecture ℹ️ Informational
RFC5738 (2010) ⛔️ LIST (UTF8) ⛔️ OBSOLETE (RFC6855 is silent on list extensions)
RFC5738 (2010) ⛔️ LIST (UTF8ONLY) ⛔️ OBSOLETE (RFC6855 is silent on list extensions)
RFC5738 (2010) ⛔️ LIST RETURN (UTF8) ⛔️ OBSOLETE (RFC6855 is silent on list extensions)
RFC5738 (2010) ⛔️ UTF8=ALL ⛔️ OBSOLETE (See RFC6855)
RFC5738 (2010) ⛔️ UTF8=APPEND ⛔️ OBSOLETE (See RFC6855)
RFC5738 (2010) ⛔️ UTF8=USER ⛔️ OBSOLETE (See RFC6855)
RFC5738 (2010) ⛔️ UTF8=ACCEPT Replaced by RFC6855 (2013)
RFC5738 (2010) ⛔️ UTF8=ONLY Replaced by RFC6855 (2013)
RFC5788 (2010) 🗄️ Keyword registry Establishes an IANA registry
RFC5802 (2010) ⏭️🔑 SASL: AUTH=SCRAM-* (rev2: SCRAM-SHA-256 replaces DIGEST-MD5)
RFC5819 (2010) LIST RETURN (STATUS)
RFC5819 (2010) ⏭️ LIST-STATUS
RFC5957 (2010) SORT=DISPLAY
RFC6154 (2011) ⏭️📬 Mbox Attr: \All 📬 All messages
RFC6154 (2011) ⏭️📬 Mbox Attr: \Archive 📬 Archived messages
RFC6154 (2011) ⏭️📬 Mbox Attr: \Drafts 📬 Messages that are working drafts
RFC6154 (2011) ⏭️📬 Mbox Attr: \Flagged 📬 Messages with the \Flagged flag
RFC6154 (2011) ⏭️📬 Mbox Attr: \Junk 📬 Messages identified as Spam/Junk
RFC6154 (2011) ⏭️📬 Mbox Attr: \Sent 📬 Sent mail
RFC6154 (2011) ⏭️📬 Mbox Attr: \Trash 📬 Messages the user has discarded
RFC6154 (2011) Resp Code: \USEATTR
RFC6154 (2011) CREATE-SPECIAL-USE
RFC6154 (2011) LIST (SPECIAL-USE)
RFC6154 (2011) LIST RETURN (SPECIAL-USE)
RFC6154 (2011) SPECIAL-USE (rev2: new mailbox attributes only)
RFC6186 (2011) DNS SRV Records for Email Updated by RFC8314, RFC8553
RFC6203 (2011) SEARCH=FUZZY
RFC6785 (2012) IMAPSIEVE=
RFC6851 (2013) ⏭️ MOVE
RFC6855 (2013) UTF8=ACCEPT (rev2: for backward compatibility with IMAP4rev1)
RFC6855 (2013) UTF8=ONLY (rev2: for backward compatibility with IMAP4rev1)
RFC6858 (2013) Resp Code: DOWNGRADED
RFC6858 (2013) Simplified Downgrading for I18n
RFC7162 (2014) Resp Code: HIGHESTMODSEQ
RFC7162 (2014) Resp Code: MODIFIED
RFC7162 (2014) Resp Code: NOMODSEQ
RFC7162 (2014) CONDSTORE
RFC7162 (2014) ⏭️ Resp Code: CLOSED
RFC7162 (2014) QRESYNC
RFC7377 (2014) MULTISEARCH
RFC7525 (2015) ⏭️💡 Recommendations for Secure TLS
RFC7628 (2015) 🔑 SASL: AUTH=OAUTHBEARER Replaces AUTH=XOAUTH2
RFC7817 (2016) ⏭️ TLS Identity Check Procedure
RFC7888 (2016) 🍋 LITERAL+
RFC7888 (2016) ⏭️ LITERAL-
RFC7889 (2016) APPENDLIMIT
RFC8314 (2018) ⏭️ Cleartext Obsolete: Use TLS
RFC8437 (2018) 🔑 UNAUTHENTICATE
RFC8438 (2018) STATUS=SIZE
RFC8440 (2018) 🔑 LIST RETURN (MYRIGHTS)
RFC8440 (2018) 🔑 LIST-MYRIGHTS
RFC8457 (2018) Keyword: $Important
RFC8457 (2018) 📬 Mbox Attr: \Important 📬 Messages deemed important to user
RFC8474 (2018) Resp Code: MAILBOXID
RFC8474 (2018) OBJECTID
RFC8508 (2019) REPLACE
RFC8514 (2019) SAVEDATE
RFC8553 (2019) 💡 DNS AttrLeaf Changes Fixing Specifications That Use Underscored Node Names
RFC8970 (2020) PREVIEW
RFC9051 (2021) 🎉 IMAP4rev2 Internet Message Access Protocol - VERSION 4rev2
RFC9051 (2021) Keyword: $Junk
RFC9051 (2021) Keyword: $NotJunk
RFC9051 (2021) Keyword: $Phishing
RFC9051 (2021) Resp code: HASCHILDREN
RFC9208 (2022) QUOTA
RFC9394 (2023) PARTIAL
MESSAGELIMIT (draft) 🚧 MESSAGELIMIT (DRAFT)
INPROGRESS (draft) 🚧 INPROGRESS (DRAFT)
INPROGRESS (draft) 🚧 Resp code: INPROGRESS (DRAFT)
UIDONLY (draft) 🚧 UIDONLY (DRAFT)
JMAPACCESS (draft) 🚧 JMAPACCESS (DRAFT)
SNOOZE (draft) 🚧📬 Mbox Attr: \Snoozed (DRAFT)
LIST-METADATA (draft) 🚧 LIST-METADATA (DRAFT)
LIST-METADATA (draft) 🚧 LIST-EXTENDED resp METADATA

IANA registries

Registry references
IMAP Capabilities RFC3501
IMAP Mailbox attributes RFC3501
SASL Mechanisms RFC4422
IMAP LIST EXTENDED RFC5258
IMAP Response codes RFC5530
IMAP Keywords RFC5788, RFC8621
vim: tw=250
; ############################################################################
; Crispin Standards Track [Page 81]
; RFC 3501 IMAPv4 March 2003
;
; 9. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF].
;
; In the case of alternative or optional rules in which a later rule
; overlaps an earlier rule, the rule which is listed earlier MUST take
; priority. For example, "\Seen" when parsed as a flag is the \Seen
; flag name and not a flag-extension, even though "\Seen" can be parsed
; as a flag-extension. Some, but not all, instances of this rule are
; noted below.
;
; Note: [ABNF] rules MUST be followed strictly; in
; particular:
;
; (1) Except as noted otherwise, all alphabetic characters
; are case-insensitive. The use of upper or lower case
; characters to define token strings is for editorial clarity
; only. Implementations MUST accept these strings in a
; case-insensitive fashion.
;
; (2) In all cases, SP refers to exactly one space. It is
; NOT permitted to substitute TAB, insert additional spaces,
; or otherwise treat SP as being equivalent to LWSP.
;
; (3) The ASCII NUL character, %x00, MUST NOT be used at any
; time.
address = "(" addr-name SP addr-adl SP addr-mailbox SP
addr-host ")"
addr-adl = nstring
; Holds route from [RFC-2822] route-addr if
; non-NIL
addr-host = nstring
; NIL indicates [RFC-2822] group syntax.
; Otherwise, holds [RFC-2822] domain name
addr-mailbox = nstring
; NIL indicates end of [RFC-2822] group; if
; non-NIL and addr-host is NIL, holds
; [RFC-2822] group name.
; Otherwise, holds [RFC-2822] local-part
; after removing [RFC-2822] quoting
; Crispin Standards Track [Page 81]
; RFC 3501 IMAPv4 March 2003
addr-name = nstring
; If non-NIL, holds phrase from [RFC-2822]
; mailbox after removing [RFC-2822] quoting
append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP
literal
astring = 1*ASTRING-CHAR / string
ASTRING-CHAR = ATOM-CHAR / resp-specials
atom = 1*ATOM-CHAR
ATOM-CHAR = <any CHAR except atom-specials>
atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards /
quoted-specials / resp-specials
authenticate = "AUTHENTICATE" SP auth-type *(CRLF base64)
auth-type = atom
; Defined by [SASL]
base64 = *(4base64-char) [base64-terminal]
base64-char = ALPHA / DIGIT / "+" / "/"
; Case-sensitive
base64-terminal = (2base64-char "==") / (3base64-char "=")
body = "(" (body-type-1part / body-type-mpart) ")"
body-extension = nstring / number /
"(" body-extension *(SP body-extension) ")"
; Future expansion. Client implementations
; MUST accept body-extension fields. Server
; implementations MUST NOT generate
; body-extension fields except as defined by
; future standard or standards-track
; revisions of this specification.
body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang
[SP body-fld-loc *(SP body-extension)]]]
; MUST NOT be returned on non-extensible
; "BODY" fetch
; Crispin Standards Track [Page 82]
; RFC 3501 IMAPv4 March 2003
body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang
[SP body-fld-loc *(SP body-extension)]]]
; MUST NOT be returned on non-extensible
; "BODY" fetch
body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP
body-fld-enc SP body-fld-octets
body-fld-desc = nstring
body-fld-dsp = "(" string SP body-fld-param ")" / nil
body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/
"QUOTED-PRINTABLE") DQUOTE) / string
body-fld-id = nstring
body-fld-lang = nstring / "(" string *(SP string) ")"
body-fld-loc = nstring
body-fld-lines = number
body-fld-md5 = nstring
body-fld-octets = number
body-fld-param = "(" string SP string *(SP string SP string) ")" / nil
body-type-1part = (body-type-basic / body-type-msg / body-type-text)
[SP body-ext-1part]
body-type-basic = media-basic SP body-fields
; MESSAGE subtype MUST NOT be "RFC822"
body-type-mpart = 1*body SP media-subtype
[SP body-ext-mpart]
body-type-msg = media-message SP body-fields SP envelope
SP body SP body-fld-lines
body-type-text = media-text SP body-fields SP body-fld-lines
capability = ("AUTH=" auth-type) / atom
; New capabilities MUST begin with "X" or be
; registered with IANA as standard or
; standards-track
; Crispin Standards Track [Page 83]
; RFC 3501 IMAPv4 March 2003
capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev1"
*(SP capability)
; Servers MUST implement the STARTTLS, AUTH=PLAIN,
; and LOGINDISABLED capabilities
; Servers which offer RFC 1730 compatibility MUST
; list "IMAP4" as the first capability.
CHAR8 = %x01-ff
; any OCTET except NUL, %x00
command = tag SP (command-any / command-auth / command-nonauth /
command-select) CRLF
; Modal based on state
command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / x-command
; Valid in all states
command-auth = append / create / delete / examine / list / lsub /
rename / select / status / subscribe / unsubscribe
; Valid only in Authenticated or Selected state
command-nonauth = login / authenticate / "STARTTLS"
; Valid only when in Not Authenticated state
command-select = "CHECK" / "CLOSE" / "EXPUNGE" / copy / fetch / store /
uid / search
; Valid only when in Selected state
continue-req = "+" SP (resp-text / base64) CRLF
copy = "COPY" SP sequence-set SP mailbox
create = "CREATE" SP mailbox
; Use of INBOX gives a NO error
date = date-text / DQUOTE date-text DQUOTE
date-day = 1*2DIGIT
; Day of month
date-day-fixed = (SP DIGIT) / 2DIGIT
; Fixed-format version of date-day
date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
"Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
date-text = date-day "-" date-month "-" date-year
; Crispin Standards Track [Page 84]
; RFC 3501 IMAPv4 March 2003
date-year = 4DIGIT
date-time = DQUOTE date-day-fixed "-" date-month "-" date-year
SP time SP zone DQUOTE
delete = "DELETE" SP mailbox
; Use of INBOX gives a NO error
digit-nz = %x31-39
; 1-9
envelope = "(" env-date SP env-subject SP env-from SP
env-sender SP env-reply-to SP env-to SP env-cc SP
env-bcc SP env-in-reply-to SP env-message-id ")"
env-bcc = "(" 1*address ")" / nil
env-cc = "(" 1*address ")" / nil
env-date = nstring
env-from = "(" 1*address ")" / nil
env-in-reply-to = nstring
env-message-id = nstring
env-reply-to = "(" 1*address ")" / nil
env-sender = "(" 1*address ")" / nil
env-subject = nstring
env-to = "(" 1*address ")" / nil
examine = "EXAMINE" SP mailbox
fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" /
fetch-att / "(" fetch-att *(SP fetch-att) ")")
fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" /
"RFC822" [".HEADER" / ".SIZE" / ".TEXT"] /
"BODY" ["STRUCTURE"] / "UID" /
"BODY" section ["<" number "." nz-number ">"] /
"BODY.PEEK" section ["<" number "." nz-number ">"]
; Crispin Standards Track [Page 85]
; RFC 3501 IMAPv4 March 2003
flag = "\Answered" / "\Flagged" / "\Deleted" /
"\Seen" / "\Draft" / flag-keyword / flag-extension
; Does not include "\Recent"
flag-extension = "\" atom
; Future expansion. Client implementations
; MUST accept flag-extension flags. Server
; implementations MUST NOT generate
; flag-extension flags except as defined by
; future standard or standards-track
; revisions of this specification.
flag-fetch = flag / "\Recent"
flag-keyword = atom
flag-list = "(" [flag *(SP flag)] ")"
flag-perm = flag / "\*"
greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF
header-fld-name = astring
header-list = "(" header-fld-name *(SP header-fld-name) ")"
list = "LIST" SP mailbox SP list-mailbox
list-mailbox = 1*list-char / string
list-char = ATOM-CHAR / list-wildcards / resp-specials
list-wildcards = "%" / "*"
literal = "{" number "}" CRLF *CHAR8
; Number represents the number of CHAR8s
login = "LOGIN" SP userid SP password
lsub = "LSUB" SP mailbox SP list-mailbox
; Crispin Standards Track [Page 86]
; RFC 3501 IMAPv4 March 2003
mailbox = "INBOX" / astring
; INBOX is case-insensitive. All case variants of
; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX
; not as an astring. An astring which consists of
; the case-insensitive sequence "I" "N" "B" "O" "X"
; is considered to be INBOX and not an astring.
; Refer to section 5.1 for further
; semantic details of mailbox names.
mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list /
"LSUB" SP mailbox-list / "SEARCH" *(SP nz-number) /
"STATUS" SP mailbox SP "(" [status-att-list] ")" /
number SP "EXISTS" / number SP "RECENT"
mailbox-list = "(" [mbx-list-flags] ")" SP
(DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox
mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag
*(SP mbx-list-oflag) /
mbx-list-oflag *(SP mbx-list-oflag)
mbx-list-oflag = "\Noinferiors" / flag-extension
; Other flags; multiple possible per LIST response
mbx-list-sflag = "\Noselect" / "\Marked" / "\Unmarked"
; Selectability flags; only one per LIST response
media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" /
"MESSAGE" / "VIDEO") DQUOTE) / string) SP
media-subtype
; Defined in [MIME-IMT]
media-message = DQUOTE "MESSAGE" DQUOTE SP DQUOTE "RFC822" DQUOTE
; Defined in [MIME-IMT]
media-subtype = string
; Defined in [MIME-IMT]
media-text = DQUOTE "TEXT" DQUOTE SP media-subtype
; Defined in [MIME-IMT]
message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att))
msg-att = "(" (msg-att-dynamic / msg-att-static)
*(SP (msg-att-dynamic / msg-att-static)) ")"
msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")"
; MAY change for a message
; Crispin Standards Track [Page 87]
; RFC 3501 IMAPv4 March 2003
msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time /
"RFC822" [".HEADER" / ".TEXT"] SP nstring /
"RFC822.SIZE" SP number /
"BODY" ["STRUCTURE"] SP body /
"BODY" section ["<" number ">"] SP nstring /
"UID" SP uniqueid
; MUST NOT change for a message
nil = "NIL"
nstring = string / nil
number = 1*DIGIT
; Unsigned 32-bit integer
; (0 <= n < 4,294,967,296)
nz-number = digit-nz *DIGIT
; Non-zero unsigned 32-bit integer
; (0 < n < 4,294,967,296)
password = astring
quoted = DQUOTE *QUOTED-CHAR DQUOTE
QUOTED-CHAR = <any TEXT-CHAR except quoted-specials> /
"\" quoted-specials
quoted-specials = DQUOTE / "\"
rename = "RENAME" SP mailbox SP mailbox
; Use of INBOX as a destination gives a NO error
response = *(continue-req / response-data) response-done
response-data = "*" SP (resp-cond-state / resp-cond-bye /
mailbox-data / message-data / capability-data) CRLF
response-done = response-tagged / response-fatal
response-fatal = "*" SP resp-cond-bye CRLF
; Server closes connection immediately
response-tagged = tag SP resp-cond-state CRLF
resp-cond-auth = ("OK" / "PREAUTH") SP resp-text
; Authentication condition
; Crispin Standards Track [Page 88]
; RFC 3501 IMAPv4 March 2003
resp-cond-bye = "BYE" SP resp-text
resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text
; Status condition
resp-specials = "]"
resp-text = ["[" resp-text-code "]" SP] text
resp-text-code = "ALERT" /
"BADCHARSET" [SP "(" astring *(SP astring) ")" ] /
capability-data / "PARSE" /
"PERMANENTFLAGS" SP "("
[flag-perm *(SP flag-perm)] ")" /
"READ-ONLY" / "READ-WRITE" / "TRYCREATE" /
"UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number /
"UNSEEN" SP nz-number /
atom [SP 1*<any TEXT-CHAR except "]">]
search = "SEARCH" [SP "CHARSET" SP astring] 1*(SP search-key)
; CHARSET argument to MUST be registered with IANA
search-key = "ALL" / "ANSWERED" / "BCC" SP astring /
"BEFORE" SP date / "BODY" SP astring /
"CC" SP astring / "DELETED" / "FLAGGED" /
"FROM" SP astring / "KEYWORD" SP flag-keyword /
"NEW" / "OLD" / "ON" SP date / "RECENT" / "SEEN" /
"SINCE" SP date / "SUBJECT" SP astring /
"TEXT" SP astring / "TO" SP astring /
"UNANSWERED" / "UNDELETED" / "UNFLAGGED" /
"UNKEYWORD" SP flag-keyword / "UNSEEN" /
; Above this line were in [IMAP2]
"DRAFT" / "HEADER" SP header-fld-name SP astring /
"LARGER" SP number / "NOT" SP search-key /
"OR" SP search-key SP search-key /
"SENTBEFORE" SP date / "SENTON" SP date /
"SENTSINCE" SP date / "SMALLER" SP number /
"UID" SP sequence-set / "UNDRAFT" / sequence-set /
"(" search-key *(SP search-key) ")"
section = "[" [section-spec] "]"
section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list /
"TEXT"
; top-level or MESSAGE/RFC822 part
section-part = nz-number *("." nz-number)
; body part nesting
; Crispin Standards Track [Page 89]
; RFC 3501 IMAPv4 March 2003
section-spec = section-msgtext / (section-part ["." section-text])
section-text = section-msgtext / "MIME"
; text other than actual body part (headers, etc.)
select = "SELECT" SP mailbox
seq-number = nz-number / "*"
; message sequence number (COPY, FETCH, STORE
; commands) or unique identifier (UID COPY,
; UID FETCH, UID STORE commands).
; * represents the largest number in use. In
; the case of message sequence numbers, it is
; the number of messages in a non-empty mailbox.
; In the case of unique identifiers, it is the
; unique identifier of the last message in the
; mailbox or, if the mailbox is empty, the
; mailbox's current UIDNEXT value.
; The server should respond with a tagged BAD
; response to a command that uses a message
; sequence number greater than the number of
; messages in the selected mailbox. This
; includes "*" if the selected mailbox is empty.
seq-range = seq-number ":" seq-number
; two seq-number values and all values between
; these two regardless of order.
; Example: 2:4 and 4:2 are equivalent and indicate
; values 2, 3, and 4.
; Example: a unique identifier sequence range of
; 3291:* includes the UID of the last message in
; the mailbox, even if that value is less than 3291.
sequence-set = (seq-number / seq-range) *("," sequence-set)
; set of seq-number values, regardless of order.
; Servers MAY coalesce overlaps and/or execute the
; sequence in any order.
; Example: a message sequence number set of
; 2,4:7,9,12:* for a mailbox with 15 messages is
; equivalent to 2,4,5,6,7,9,12,13,14,15
; Example: a message sequence number set of *:4,5:7
; for a mailbox with 10 messages is equivalent to
; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and
; overlap coalesced to be 4,5,6,7,8,9,10.
status = "STATUS" SP mailbox SP
"(" status-att *(SP status-att) ")"
; Crispin Standards Track [Page 90]
; RFC 3501 IMAPv4 March 2003
status-att = "MESSAGES" / "RECENT" / "UIDNEXT" / "UIDVALIDITY" /
"UNSEEN"
status-att-list = status-att SP number *(SP status-att SP number)
store = "STORE" SP sequence-set SP store-att-flags
store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP
(flag-list / (flag *(SP flag)))
string = quoted / literal
subscribe = "SUBSCRIBE" SP mailbox
tag = 1*<any ASTRING-CHAR except "+">
text = 1*TEXT-CHAR
TEXT-CHAR = <any CHAR except CR and LF>
time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
; Hours minutes seconds
uid = "UID" SP (copy / fetch / search / store)
; Unique identifiers used instead of message
; sequence numbers
uniqueid = nz-number
; Strictly ascending
unsubscribe = "UNSUBSCRIBE" SP mailbox
userid = astring
x-command = "X" atom <experimental command arguments>
zone = ("+" / "-") 4DIGIT
; Signed four-digit value of hhmm representing
; hours and minutes east of Greenwich (that is,
; the amount that the given time differs from
; Universal Time). Subtracting the timezone
; from the given time will give the UT form.
; The Universal Time zone is "+0000".
; ############################################################################
; RFC3501 Errata
; Source of RFC: IETF - NON WORKING GROUP
; Area Assignment: app
;
; Errata ID: 261
; Status: Verified
; Type: Technical
; Publication Format(s) : TEXT
; Reported By: Mark Crispin
; Date Reported: 2007-06-13
; Formal Syntax, Page 84:
; old:
CHAR8 = %x01-ff
; any OCTET except NUL, %x00
; new:
CHAR8 = %x01-ff
; any OCTET except NUL, %x00
charset = atom / quoted
; -----
; Formal Syntax, Page 89:
; old:
resp-text-code = "ALERT" /
"BADCHARSET" [SP "(" astring *(SP astring) ")" ] /
; new:
resp-text-code = "ALERT" /
"BADCHARSET" [SP "(" charset *(SP charset) ")" ] /
; -----
; Formal Syntax, Page 89:
; old:
search = "SEARCH" [SP "CHARSET" SP astring] 1*(SP search-key)
; new:
search = "SEARCH" [SP "CHARSET" SP charset] 1*(SP search-key)
; -----
; Formal Syntax, Page 90:
; old:
sequence-set = (seq-number / seq-range) *("," sequence-set)
; new:
sequence-set = (seq-number / seq-range) ["," sequence-set]
; -----
; Formal Syntax, Page 90:
; old:
status-att-list = status-att SP number *(SP status-att SP number)
; new:
status-att-val = ("MESSAGES" SP number) / ("RECENT" SP number) /
("UIDNEXT" SP nz-number) / ("UIDVALIDITY" SP nz-number) /
("UNSEEN" SP number)
status-att-list = status-att-val *(SP status-att-val)
; ############################################################################
; Crocker & Overell Standards Track [Page 12]
; RFC 5234 ABNF January 2008
;
; ...
;
; Appendix B. Core ABNF of ABNF
;
; This appendix contains some basic rules that are in common use.
; Basic rules are in uppercase. Note that these rules are only valid
; for ABNF encoded in 7-bit ASCII or in characters sets that are a
; superset of 7-bit ASCII.
;
; B.1. Core Rules
;
; Certain basic rules are in uppercase, such as SP, HTAB, CRLF, DIGIT,
; ALPHA, etc.
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
BIT = "0" / "1"
CHAR = %x01-7F
; any 7-bit US-ASCII character,
; excluding NUL
; Crocker & Overell Standards Track [Page 13]
; RFC 5234 ABNF January 2008
CR = %x0D
; carriage return
CRLF = CR LF
; Internet standard newline
CTL = %x00-1F / %x7F
; controls
DIGIT = %x30-39
; 0-9
DQUOTE = %x22
; " (Double Quote)
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
HTAB = %x09
; horizontal tab
LF = %x0A
; linefeed
LWSP = *(WSP / CRLF WSP)
; Use of this linear-white-space rule
; permits lines containing only white
; space that are no longer legal in
; mail headers and have caused
; interoperability problems in other
; contexts.
; Do not use when defining mail
; headers and use with caution in
; other contexts.
OCTET = %x00-FF
; 8 bits of data
SP = %x20
VCHAR = %x21-7E
; visible (printing) characters
WSP = SP / HTAB
; white space
; ############################################################################
; Myers Standards Track [Page 3]
; RFC 2087 QUOTA January 1997
;
; ...
;
; 6. Formal syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) notation as specified in RFC 822 with one exception; the
; delimiter used with the "#" construct is a single space (SP) and not
; one or more commas.
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lower case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
;
;
; Myers Standards Track [Page 4]
; RFC 2087 QUOTA January 1997
getquota ::= "GETQUOTA" SP astring
getquotaroot ::= "GETQUOTAROOT" SP astring
quota_list ::= "(" #quota_resource ")"
quota_resource ::= atom SP number SP number
quota_response ::= "QUOTA" SP astring SP quota_list
quotaroot_response
::= "QUOTAROOT" SP astring *(SP astring)
setquota ::= "SETQUOTA" SP astring SP setquota_list
setquota_list ::= "(" 0#setquota_resource ")"
setquota_resource ::= atom SP number
; ############################################################################
; RFC 7888 Obsoletes RFC 2088 (1997)
;
; Melnikov Standards Track [Page 5]
; RFC 7888 IMAP4 Non-synchronizing Literals May 2016
;
; ...
;
; 8. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF].
;
; Non-terminals referenced but not defined below are as defined by
; [RFC3501].
literal = "{" number ["+"] "}" CRLF *CHAR8
; Number represents the number of CHAR8 octets
CHAR8 = <defined in RFC 3501>
literal8 = <defined in RFC 4466>
; ############################################################################
; Leiba Standards Track [Page 2]
; RFC 2177 IMAP4 IDLE command June 1997
;
; ...
;
; 4. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) notation as specified in [RFC-822] as modified by [IMAP4].
; Non-terminals referenced but not defined below are as defined by
; [IMAP4].
command_auth ::= append / create / delete / examine / list / lsub /
rename / select / status / subscribe / unsubscribe
/ idle
;; Valid only in Authenticated or Selected state
idle ::= "IDLE" CRLF "DONE"
; ############################################################################
; RFC 5092 Obsoletes RFC 2192 (1997)
;
; Melnikov & Newman Standards Track [Page 16]
; RFC 5092 IMAP URL Scheme November 2007
;
; ...
;
; 11. ABNF for IMAP URL Scheme
;
; Formal syntax is defined using ABNF [ABNF], extending the ABNF rules
; in Section 9 of [IMAP4]. Elements not defined here can be found in
; [ABNF], [IMAP4], [IMAPABNF], or [URI-GEN]. Strings are not case
; sensitive, and free insertion of linear white space is not permitted.
sub-delims-sh = "!" / "$" / "'" / "(" / ")" /
"*" / "+" / ","
;; Same as [URI-GEN] sub-delims,
;; but without ";", "&" and "=".
uchar = unreserved / sub-delims-sh / pct-encoded
achar = uchar / "&" / "="
;; Same as [URI-GEN] 'unreserved / sub-delims /
;; pct-encoded', but ";" is disallowed.
bchar = achar / ":" / "@" / "/"
; Melnikov & Newman Standards Track [Page 17]
; RFC 5092 IMAP URL Scheme November 2007
enc-auth-type = 1*achar
; %-encoded version of [IMAP4] "auth-type"
enc-mailbox = 1*bchar
; %-encoded version of [IMAP4] "mailbox"
enc-search = 1*bchar
; %-encoded version of [IMAPABNF]
; "search-program". Note that IMAP4
; literals may not be used in
; a "search-program", i.e., only
; quoted or non-synchronizing
; literals (if the server supports
; LITERAL+ [LITERAL+]) are allowed.
enc-section = 1*bchar
; %-encoded version of [IMAP4] "section-spec"
enc-user = 1*achar
; %-encoded version of [IMAP4] authorization
; identity or "userid".
imapurl = "imap://" iserver ipath-query
; Defines an absolute IMAP URL
ipath-query = ["/" [ icommand ]]
; Corresponds to "path-abempty [ "?" query ]"
; in [URI-GEN]
; Generic syntax for relative URLs is defined in Section 4.2 of
; [URI-GEN]. For ease of implementation, the relative IMAP URL syntax
; is defined below:
imapurl-rel = inetwork-path
/ iabsolute-path
/ irelative-path
/ ipath-empty
inetwork-path = "//" iserver ipath-query
; Corresponds to '"//" authority path-abempty
; [ "?" query ]' in [URI-GEN]
iabsolute-path = "/" [ icommand ]
; icommand, if present, MUST NOT start with '/'.
;
; Corresponds to 'path-absolute [ "?" query ]'
; in [URI-GEN]
; Melnikov & Newman Standards Track [Page 18]
; RFC 5092 IMAP URL Scheme November 2007
irelative-path = imessagelist /
imsg-or-part
; Corresponds to 'path-noscheme [ "?" query ]'
; in [URI-GEN]
imsg-or-part = ( imailbox-ref "/" iuid-only ["/" isection-only]
["/" ipartial-only] ) /
( iuid-only ["/" isection-only]
["/" ipartial-only] ) /
( isection-only ["/" ipartial-only] ) /
ipartial-only
ipath-empty = 0<pchar>
; Zero characters.
; The same-document reference.
; The following three rules are only used in the presence of the IMAP
; [URLAUTH] extension:
authimapurl = "imap://" iserver "/" imessagepart
; Same as "imapurl" when "[icommand]" is
; "imessagepart"
authimapurlfull = authimapurl iurlauth
; Same as "imapurl" when "[icommand]" is
; "imessagepart iurlauth"
authimapurlrump = authimapurl iurlauth-rump
enc-urlauth = 32*HEXDIG
iurlauth = iurlauth-rump iua-verifier
iua-verifier = ":" uauth-mechanism ":" enc-urlauth
iurlauth-rump = [expire] ";URLAUTH=" access
access = ("submit+" enc-user) / ("user+" enc-user) /
"authuser" / "anonymous"
expire = ";EXPIRE=" date-time
; date-time is defined in [DATETIME]
uauth-mechanism = "INTERNAL" / 1*(ALPHA / DIGIT / "-" / ".")
; Case-insensitive.
; New mechanisms MUST be registered with IANA.
; Melnikov & Newman Standards Track [Page 19]
; RFC 5092 IMAP URL Scheme November 2007
iauth = ";AUTH=" ( "*" / enc-auth-type )
icommand = imessagelist /
imessagepart [iurlauth]
imailbox-ref = enc-mailbox [uidvalidity]
imessagelist = imailbox-ref [ "?" enc-search ]
; "enc-search" is [URI-GEN] "query".
imessagepart = imailbox-ref iuid [isection] [ipartial]
ipartial = "/" ipartial-only
ipartial-only = ";PARTIAL=" partial-range
isection = "/" isection-only
isection-only = ";SECTION=" enc-section
iserver = [iuserinfo "@"] host [ ":" port ]
; This is the same as "authority" defined
; in [URI-GEN]. See [URI-GEN] for "host"
; and "port" definitions.
iuid = "/" iuid-only
iuid-only = ";UID=" nz-number
; See [IMAP4] for "nz-number" definition
iuserinfo = enc-user [iauth] / [enc-user] iauth
; conforms to the generic syntax of
; "userinfo" as defined in [URI-GEN].
partial-range = number ["." nz-number]
; partial FETCH. The first number is
; the offset of the first byte,
; the second number is the length of
; the fragment.
uidvalidity = ";UIDVALIDITY=" nz-number
; See [IMAP4] for "nz-number" definition
; ############################################################################
; Gahrns Standards Track [Page 6]
; RFC 2193 IMAP4 Mailbox Referrals September 1997
;
; ...
;
; 6. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) as described in [ABNF].
list_mailbox = <list_mailbox> as defined in [RFC-2060]
mailbox = <mailbox> as defined in [RFC-2060]
mailbox_referral = <tag> SPACE "NO" SPACE
<referral_response_code> (text / text_mime2)
; See [RFC-2060] for <tag>, text and text_mime2 definition
; Gahrns Standards Track [Page 7]
; RFC 2193 IMAP4 Mailbox Referrals September 1997
referral_response_code = "[" "REFERRAL" 1*(SPACE <url>) "]"
; See [RFC-1738] for <url> definition
rlist = "RLIST" SPACE mailbox SPACE list_mailbox
rlsub = "RLSUB" SPACE mailbox SPACE list_mailbox
; ############################################################################
; Gahrns & Newman Standards Track [Page 7]
; RFC 2342 IMAP4 Namespace May 1998
;
; 6. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) as described in [ABNF].
atom = <atom>
; <atom> as defined in [RFC-2060]
Namespace = nil / "(" 1*( "(" string SP (<"> QUOTED_CHAR <"> /
nil) *(Namespace_Response_Extension) ")" ) ")"
Namespace_Command = "NAMESPACE"
Namespace_Response_Extension = SP string SP "(" string *(SP string)
")"
Namespace_Response = "*" SP "NAMESPACE" SP Namespace SP Namespace SP
Namespace
; The first Namespace is the Personal Namespace(s)
; The second Namespace is the Other Users' Namespace(s)
; The third Namespace is the Shared Namespace(s)
nil = <nil>
; <nil> as defined in [RFC-2060]
QUOTED_CHAR = <QUOTED_CHAR>
; <QUOTED_CHAR> as defined in [RFC-2060]
string = <string>
; <string> as defined in [RFC-2060]
; Note that the namespace prefix is to a mailbox and following
; IMAP4 convention, any international string in the NAMESPACE
; response MUST be of modified UTF-7 format as described in
; [RFC-2060].
; ############################################################################
; Showalter Standards Track [Page 4]
; RFC 2971 IMAP4 ID extension October 2000
;
;
; 4. Formal Syntax
;
; This syntax is intended to augment the grammar specified in
; [IMAP4rev1] in order to provide for the ID command. This
; specification uses the augmented Backus-Naur Form (BNF) notation as
; used in [IMAP4rev1].
command_any ::= "CAPABILITY" / "LOGOUT" / "NOOP" / x_command / id
;; adds id command to command_any in [IMAP4rev1]
id ::= "ID" SPACE id_params_list
id_response ::= "ID" SPACE id_params_list
id_params_list ::= "(" #(string SPACE nstring) ")" / nil
;; list of field value pairs
response_data ::= "*" SPACE (resp_cond_state / resp_cond_bye /
mailbox_data / message_data / capability_data / id_response)
; ############################################################################
; Crispin Standards Track [Page 3]
; RFC 3502 IMAP MULTIAPPEND March 2003
;
; ...
;
; Modification to IMAP4rev1 Base Protocol Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF].
append = "APPEND" SP mailbox 1*append-message
append-message = [SP flag-list] [SP date-time] SP literal
; Crispin Standards Track [Page 4]
; RFC 3502 IMAP MULTIAPPEND March 2003
;
;
; MULTIAPPEND Interaction with UIDPLUS Extension
;
; Servers which support both MULTIAPPEND and [UIDPLUS] will have the
; "resp-code-apnd" rule modified as follows:
resp-code-apnd = "APPENDUID" SP nz-number SP set
; That is, the APPENDUID response code returns as many UIDs as there
; were messages appended in the multiple append. The UIDs returned
; should be in the order the articles where appended. The message set
; may not contain extraneous UIDs or the symbol "*".
; ############################################################################
; Melnikov Standards Track [Page 6]
; RFC 3503 MDN profile for IMAP March 2003
;
; ...
;
; 7. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) notation as specified in [RFC-822], as modified by
; [IMAP4]. Non-terminals referenced, but not defined below, are as
; defined by [IMAP4].
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lower case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
flag_keyword ::= "$MDNSent" / other_keywords
other_keywords ::= atom
; ############################################################################
; Nerenberg Standards Track [Page 4]
; RFC 3516 IMAP4 Binary Content Extension April 2003
;
; ...
;
; 7. Formal Protocol Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (ABNF) notation as used in [ABNF], and incorporates by reference
; the Core Rules defined in that document.
;
; This syntax augments the grammar specified in [IMAP4rev1].
append =/ "APPEND" SP mailbox [SP flag-list]
[SP date-time] SP literal8
fetch-att =/ "BINARY" [".PEEK"] section-binary [partial]
/ "BINARY.SIZE" section-binary
literal8 = "~{" number "}" CRLF *OCTET
; <number> represents the number of OCTETs
; in the response string.
msg-att-static =/ "BINARY" section-binary SP (nstring / literal8)
/ "BINARY.SIZE" section-binary SP number
partial = "<" number "." nz-number ">"
resp-text-code =/ "UNKNOWN-CTE"
section-binary = "[" [section-part] "]"
; ############################################################################
; Melnikov Standards Track [Page 2]
; RFC 3691 IMAP UNSELECT command February 2004
;
; 4. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF]. Non-terminals
; referenced but not defined below are as defined by [IMAP4].
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lower case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
command-select /= "UNSELECT"
; ############################################################################
; Melnikov Standards Track [Page 20]
; RFC 4314 IMAP ACL December 2005
;
; ...
;
; 7. Formal Syntax
;
; Formal syntax is defined using ABNF [ABNF], extending the ABNF rules
; in Section 9 of [IMAP4]. Elements not defined here can be found in
; [ABNF] and [IMAP4].
;
; Except as noted otherwise, all alphabetic characters are case
; insensitive. The use of uppercase or lowercase characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
LOWER-ALPHA = %x61-7A ;; a-z
acl-data = "ACL" SP mailbox *(SP identifier SP
rights)
capability =/ rights-capa
;;capability is defined in [IMAP4]
command-auth =/ setacl / deleteacl / getacl /
listrights / myrights
;;command-auth is defined in [IMAP4]
deleteacl = "DELETEACL" SP mailbox SP identifier
getacl = "GETACL" SP mailbox
identifier = astring
listrights = "LISTRIGHTS" SP mailbox SP identifier
listrights-data = "LISTRIGHTS" SP mailbox SP identifier
SP rights *(SP rights)
; Melnikov Standards Track [Page 21]
; RFC 4314 IMAP ACL December 2005
mailbox-data =/ acl-data / listrights-data / myrights-data
;;mailbox-data is defined in [IMAP4]
mod-rights = astring
;; +rights to add, -rights to remove
;; rights to replace
myrights = "MYRIGHTS" SP mailbox
myrights-data = "MYRIGHTS" SP mailbox SP rights
new-rights = 1*LOWER-ALPHA
;; MUST include "t", "e", "x", and "k".
;; MUST NOT include standard rights listed
;; in section 2.2
rights = astring
;; only lowercase ASCII letters and digits
;; are allowed.
rights-capa = "RIGHTS=" new-rights
;; RIGHTS=... capability
setacl = "SETACL" SP mailbox SP identifier
SP mod-rights
; ############################################################################
; Crispin Standards Track [Page 4]
; RFC 4315 IMAP - UIDPLUS Extension December 2005
;
; ...
;
; 4. Formal Syntax
;
; Formal syntax is defined using ABNF [ABNF], which extends the ABNF
; rules defined in [IMAP]. The IMAP4 ABNF should be imported before
; attempting to validate these rules.
append-uid = uniqueid
capability =/ "UIDPLUS"
; Crispin Standards Track [Page 5]
; RFC 4315 IMAP - UIDPLUS Extension December 2005
command-select =/ uid-expunge
resp-code-apnd = "APPENDUID" SP nz-number SP append-uid
resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set
resp-text-code =/ resp-code-apnd / resp-code-copy / "UIDNOTSTICKY"
; incorporated before the expansion rule of
; atom [SP 1*<any TEXT-CHAR except "]">]
; that appears in [IMAP]
uid-expunge = "UID" SP "EXPUNGE" SP sequence-set
uid-set = (uniqueid / uid-range) *("," uid-set)
uid-range = (uniqueid ":" uniqueid)
; two uniqueid values and all values
; between these two regards of order.
; Example: 2:4 and 4:2 are equivalent.
; Servers that support [MULTIAPPEND] will have the following extension
; to the above rules:
append-uid =/ uid-set
; only permitted if client uses [MULTIAPPEND]
; to append multiple messages.
; ############################################################################
; Melnikov & Daboo Standards Track [Page 8]
; RFC 4466 Collected Extensions to IMAP4 ABNF April 2006
;
; 3. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF].
;
; Non-terminals referenced but not defined below are as defined by
; [IMAP4].
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of uppercase or lowercase characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
append = "APPEND" SP mailbox 1*append-message
;; only a single append-message may appear
;; if MULTIAPPEND [MULTIAPPEND] capability
;; is not present
append-message = append-opts SP append-data
append-ext = append-ext-name SP append-ext-value
;; This non-terminal define extensions to
;; to message metadata.
append-ext-name = tagged-ext-label
append-ext-value= tagged-ext-val
;; This non-terminal shows recommended syntax
;; for future extensions.
append-data = literal / literal8 / append-data-ext
append-data-ext = tagged-ext
;; This non-terminal shows recommended syntax
;; for future extensions,
;; i.e., a mandatory label followed
;; by parameters.
append-opts = [SP flag-list] [SP date-time] *(SP append-ext)
;; message metadata
charset = atom / quoted
;; Exact syntax is defined in [CHARSET].
create = "CREATE" SP mailbox
[create-params]
;; Use of INBOX gives a NO error.
; Melnikov & Daboo Standards Track [Page 9]
; RFC 4466 Collected Extensions to IMAP4 ABNF April 2006
create-params = SP "(" create-param *( SP create-param) ")"
create-param-name = tagged-ext-label
create-param = create-param-name [SP create-param-value]
create-param-value= tagged-ext-val
;; This non-terminal shows recommended syntax
;; for future extensions.
esearch-response = "ESEARCH" [search-correlator] [SP "UID"]
*(SP search-return-data)
;; Note that SEARCH and ESEARCH responses
;; SHOULD be mutually exclusive,
;; i.e., only one of the response types
;; should be
;; returned as a result of a command.
examine = "EXAMINE" SP mailbox [select-params]
;; modifies the original IMAP EXAMINE command
;; to accept optional parameters
fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" /
"FAST" / fetch-att /
"(" fetch-att *(SP fetch-att) ")")
[fetch-modifiers]
;; modifies the original IMAP4 FETCH command to
;; accept optional modifiers
fetch-modifiers = SP "(" fetch-modifier *(SP fetch-modifier) ")"
fetch-modifier = fetch-modifier-name [ SP fetch-modif-params ]
fetch-modif-params = tagged-ext-val
;; This non-terminal shows recommended syntax
;; for future extensions.
fetch-modifier-name = tagged-ext-label
literal8 = "~{" number ["+"] "}" CRLF *OCTET
;; A string that might contain NULs.
;; <number> represents the number of OCTETs
;; in the response string.
;; The "+" is only allowed when both LITERAL+ and
;; BINARY extensions are supported by the server.
; Melnikov & Daboo Standards Track [Page 10]
; RFC 4466 Collected Extensions to IMAP4 ABNF April 2006
mailbox-data =/ Namespace-Response /
esearch-response
Namespace = nil / "(" 1*Namespace-Descr ")"
Namespace-Command = "NAMESPACE"
Namespace-Descr = "(" string SP
(DQUOTE QUOTED-CHAR DQUOTE / nil)
*(Namespace-Response-Extension) ")"
Namespace-Response-Extension = SP string SP
"(" string *(SP string) ")"
Namespace-Response = "NAMESPACE" SP Namespace
SP Namespace SP Namespace
;; This response is currently only allowed
;; if the IMAP server supports [NAMESPACE].
;; The first Namespace is the Personal Namespace(s)
;; The second Namespace is the Other Users' Namespace(s)
;; The third Namespace is the Shared Namespace(s)
rename = "RENAME" SP mailbox SP mailbox
[rename-params]
;; Use of INBOX as a destination gives
;; a NO error, unless rename-params
;; is not empty.
rename-params = SP "(" rename-param *( SP rename-param) ")"
rename-param = rename-param-name [SP rename-param-value]
rename-param-name = tagged-ext-label
rename-param-value= tagged-ext-val
;; This non-terminal shows recommended syntax
;; for future extensions.
response-data = "*" SP response-payload CRLF
response-payload= resp-cond-state / resp-cond-bye /
mailbox-data / message-data / capability-data
search = "SEARCH" [search-return-opts]
SP search-program
search-correlator = SP "(" "TAG" SP tag-string ")"
; Melnikov & Daboo Standards Track [Page 11]
; RFC 4466 Collected Extensions to IMAP4 ABNF April 2006
search-program = ["CHARSET" SP charset SP]
search-key *(SP search-key)
;; CHARSET argument to SEARCH MUST be
;; registered with IANA.
search-return-data = search-modifier-name SP search-return-value
;; Note that not every SEARCH return option
;; is required to have the corresponding
;; ESEARCH return data.
search-return-opts = SP "RETURN" SP "(" [search-return-opt
*(SP search-return-opt)] ")"
search-return-opt = search-modifier-name [SP search-mod-params]
search-return-value = tagged-ext-val
;; Data for the returned search option.
;; A single "nz-number"/"number" value
;; can be returned as an atom (i.e., without
;; quoting). A sequence-set can be returned
;; as an atom as well.
search-modifier-name = tagged-ext-label
search-mod-params = tagged-ext-val
;; This non-terminal shows recommended syntax
;; for future extensions.
select = "SELECT" SP mailbox [select-params]
;; modifies the original IMAP SELECT command to
;; accept optional parameters
select-params = SP "(" select-param *(SP select-param) ")"
select-param = select-param-name [SP select-param-value]
;; a parameter to SELECT may contain one or
;; more atoms and/or strings and/or lists.
select-param-name= tagged-ext-label
select-param-value= tagged-ext-val
;; This non-terminal shows recommended syntax
;; for future extensions.
status-att-list = status-att-val *(SP status-att-val)
;; Redefines status-att-list from RFC 3501.
;; status-att-val is defined in RFC 3501 errata
; Melnikov & Daboo Standards Track [Page 12]
; RFC 4466 Collected Extensions to IMAP4 ABNF April 2006
status-att-val = ("MESSAGES" SP number) /
("RECENT" SP number) /
("UIDNEXT" SP nz-number) /
("UIDVALIDITY" SP nz-number) /
("UNSEEN" SP number)
;; Extensions to the STATUS responses
;; should extend this production.
;; Extensions should use the generic
;; syntax defined by tagged-ext.
store = "STORE" SP sequence-set [store-modifiers]
SP store-att-flags
;; extend [IMAP4] STORE command syntax
;; to allow for optional store-modifiers
store-modifiers = SP "(" store-modifier *(SP store-modifier)
")"
store-modifier = store-modifier-name [SP store-modif-params]
store-modif-params = tagged-ext-val
;; This non-terminal shows recommended syntax
;; for future extensions.
store-modifier-name = tagged-ext-label
tag-string = string
;; tag of the command that caused
;; the ESEARCH response, sent as
;; a string.
tagged-ext = tagged-ext-label SP tagged-ext-val
;; recommended overarching syntax for
;; extensions
tagged-ext-label = tagged-label-fchar *tagged-label-char
;; Is a valid RFC 3501 "atom".
tagged-label-fchar = ALPHA / "-" / "_" / "."
tagged-label-char = tagged-label-fchar / DIGIT / ":"
; Melnikov & Daboo Standards Track [Page 13]
; RFC 4466 Collected Extensions to IMAP4 ABNF April 2006
tagged-ext-comp = astring /
tagged-ext-comp *(SP tagged-ext-comp) /
"(" tagged-ext-comp ")"
;; Extensions that follow this general
;; syntax should use nstring instead of
;; astring when appropriate in the context
;; of the extension.
;; Note that a message set or a "number"
;; can always be represented as an "atom".
;; An URL should be represented as
;; a "quoted" string.
tagged-ext-simple = sequence-set / number
tagged-ext-val = tagged-ext-simple /
"(" [tagged-ext-comp] ")"
; ############################################################################
; Crispin Standards Track [Page 12]
; RFC 4467 IMAP - URLAUTH Extension May 2006
;
; ...
;
; 9. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF].
;
; The following modifications are made to the Formal Syntax in [IMAP]:
resetkey = "RESETKEY" [SP mailbox *(SP mechanism)]
capability =/ "URLAUTH"
command-auth =/ resetkey / genurlauth / urlfetch
resp-text-code =/ "URLMECH" SP "INTERNAL" *(SP mechanism ["=" base64])
genurlauth = "GENURLAUTH" 1*(SP url-rump SP mechanism)
genurlauth-data = "*" SP "GENURLAUTH" 1*(SP url-full)
; Crispin Standards Track [Page 13]
; RFC 4467 IMAP - URLAUTH Extension May 2006
url-full = astring
; contains authimapurlfull as defined below
url-rump = astring
; contains authimapurlrump as defined below
urlfetch = "URLFETCH" 1*(SP url-full)
urlfetch-data = "*" SP "URLFETCH" 1*(SP url-full SP nstring)
; The following extensions are made to the Formal Syntax in [IMAPURL]:
authimapurl = "imap://" enc-user [iauth] "@" hostport "/"
imessagepart
; replaces "imapurl" and "iserver" rules for
; URLAUTH authorized URLs
authimapurlfull = authimapurl iurlauth
authimapurlrump = authimapurl iurlauth-rump
enc-urlauth = 32*HEXDIG
enc-user = 1*achar
; same as "enc_user" in RFC 2192
iurlauth = iurlauth-rump ":" mechanism ":" enc-urlauth
iurlauth-rump = [expire] ";URLAUTH=" access
access = ("submit+" enc-user) / ("user+" enc-user) /
"authuser" / "anonymous"
expire = ";EXPIRE=" date-time
; date-time defined in [DATETIME]
mechanism = "INTERNAL" / 1*(ALPHA / DIGIT / "-" / ".")
; case-insensitive
; new mechanisms MUST be registered with IANA
; ############################################################################
; Resnick Standards Track [Page 4]
; RFC 4469 IMAP CATENATE Extension April 2006
;
; ...
;
; 5. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) [7] notation. Elements not defined here can be found in
; the formal syntax of the ABNF [7], IMAP [1], and IMAP ABNF extensions
; [8] specifications. Note that capability and resp-text-code are
; extended from the IMAP [1] specification and append-data is extended
; from the IMAP ABNF extensions [8] specification.
append-data =/ "CATENATE" SP "(" cat-part *(SP cat-part) ")"
cat-part = text-literal / url
text-literal = "TEXT" SP literal
url = "URL" SP astring
; The astring in the definition of url and the url-resp-text in the
; definition of badurl-response-code each contain an imapurl as defined
; by [2].
resp-text-code =/ toobig-response-code / badurl-response-code
toobig-response-code = "TOOBIG"
badurl-response-code = "BADURL" SP url-resp-text
url-resp-text = 1*(%x01-09 /
%x0B-0C /
%x0E-5B /
%x5D-FE) ; Any TEXT-CHAR except "]"
; The astring in the definition of url and the url-resp-text in the
; definition of badurl-response-code each contain an imapurl as defined
; by [2].
capability =/ "CATENATE"
; ############################################################################
; RFC 4469 Errata
; Source of RFC: lemonade (app)
;
; Errata ID: 2002
; Status: Verified
; Type: Technical
; Publication Format(s) : TEXT
; Reported By: Mike Abbott
; Date Reported: 2010-01-14
; Verifier Name: Alexey Melnikov
; Date Verified: 2010-04-02
; Section 5 says:
url-resp-text = 1*(%x01-09 /
%x0B-0C /
%x0E-5B /
%x5D-FE) ; Any TEXT-CHAR except "]"
; It should say:
url-resp-text = 1*(%x01-09 /
%x0B-0C /
%x0E-5C /
%x5E-FE) ; Any TEXT-CHAR except "]"
; Notes:
;
; The skipped character %x5C is "\" not "]". I think the intent is to omit "]"
; since url-resp-text is used exclusively inside a [BADURL url-resp-text]
; response code, and they want to avoid aliasing the closing "]".
; ############################################################################
; RFC 7162 Obsoletes: 4551 (2006), 5162 (2008)
;
; Melnikov & Cridland Standards Track [Page 43]
; RFC 7162 IMAP CONDSTORE & QRESYNC May 2014
;
; ...
;
; 7. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC5234].
;
; Non-terminals referenced but not defined below are as defined by
; [RFC5234], [RFC3501], or [RFC4466].
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper- or lower-case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
capability =/ "CONDSTORE" / "QRESYNC"
status-att =/ "HIGHESTMODSEQ"
;; Extends non-terminal defined in [RFC3501].
status-att-val =/ "HIGHESTMODSEQ" SP mod-sequence-valzer
;; Extends non-terminal defined in [RFC4466].
;; Value 0 denotes that the mailbox doesn't
;; support persistent mod-sequences
;; as described in Section 3.1.2.2.
; Melnikov & Cridland Standards Track [Page 44]
; RFC 7162 IMAP CONDSTORE & QRESYNC May 2014
store-modifier =/ "UNCHANGEDSINCE" SP mod-sequence-valzer
;; Only a single "UNCHANGEDSINCE" may be
;; specified in a STORE operation.
fetch-modifier =/ chgsince-fetch-mod
;; Conforms to the generic "fetch-modifier"
;; syntax defined in [RFC4466].
chgsince-fetch-mod = "CHANGEDSINCE" SP mod-sequence-value
;; CHANGEDSINCE FETCH modifier conforms to
;; the fetch-modifier syntax.
fetch-att =/ fetch-mod-sequence
;; Modifies original IMAP4 fetch-att.
fetch-mod-sequence = "MODSEQ"
fetch-mod-resp = "MODSEQ" SP "(" permsg-modsequence ")"
msg-att-dynamic =/ fetch-mod-resp
search-key =/ search-modsequence
;; Modifies original IMAP4 search-key.
;;
;; This change applies to all commands
;; referencing this non-terminal -- in
;; particular, SEARCH, SORT, and THREAD.
search-modsequence = "MODSEQ" [search-modseq-ext] SP
mod-sequence-valzer
search-modseq-ext = SP entry-name SP entry-type-req
resp-text-code =/ "HIGHESTMODSEQ" SP mod-sequence-value /
"NOMODSEQ" /
"MODIFIED" SP sequence-set
entry-name = entry-flag-name
; Melnikov & Cridland Standards Track [Page 45]
; RFC 7162 IMAP CONDSTORE & QRESYNC May 2014
entry-flag-name = DQUOTE "/flags/" attr-flag DQUOTE
;; Each system or user-defined flag <flag>
;; is mapped to "/flags/<flag>".
;;
;; <entry-flag-name> follows the escape rules
;; used by "quoted" string as described in
;; Section 4.3 of [RFC3501]; e.g., for the
;; flag \Seen, the corresponding <entry-name>
;; is "/flags/\\seen", and for the flag
;; $MDNSent, the corresponding <entry-name>
;; is "/flags/$mdnsent".
entry-type-resp = "priv" / "shared"
;; Metadata item type.
entry-type-req = entry-type-resp / "all"
;; Perform SEARCH operation on a private
;; metadata item, shared metadata item,
;; or both.
permsg-modsequence = mod-sequence-value
;; Per-message mod-sequence.
mod-sequence-value = 1*DIGIT
;; Positive unsigned 63-bit integer
;; (mod-sequence)
;; (1 <= n <= 9,223,372,036,854,775,807).
mod-sequence-valzer = "0" / mod-sequence-value
search-sort-mod-seq = "(" "MODSEQ" SP mod-sequence-value ")"
select-param =/ condstore-param
;; Conforms to the generic "select-param"
;; non-terminal syntax defined in [RFC4466].
condstore-param = "CONDSTORE"
mailbox-data =/ "SEARCH" [1*(SP nz-number) SP
search-sort-mod-seq]
sort-data = "SORT" [1*(SP nz-number) SP
search-sort-mod-seq]
; Updates the SORT response from RFC 5256.
; Melnikov & Cridland Standards Track [Page 46]
; RFC 7162 IMAP CONDSTORE & QRESYNC May 2014
attr-flag = "\\Answered" / "\\Flagged" / "\\Deleted" /
"\\Seen" / "\\Draft" / attr-flag-keyword /
attr-flag-extension
;; Does not include "\\Recent".
attr-flag-extension = "\\" atom
;; Future expansion. Client implementations
;; MUST accept flag-extension flags. Server
;; implementations MUST NOT generate
;; flag-extension flags, except as defined by
;; future standards or Standards Track
;; revisions of [RFC3501].
attr-flag-keyword = atom
select-param =/ "QRESYNC" SP "(" uidvalidity SP
mod-sequence-value [SP known-uids]
[SP seq-match-data] ")"
;; Conforms to the generic select-param
;; syntax defined in [RFC4466].
seq-match-data = "(" known-sequence-set SP known-uid-set ")"
uidvalidity = nz-number
known-uids = sequence-set
;; Sequence of UIDs; "*" is not allowed.
known-sequence-set = sequence-set
;; Set of message numbers corresponding to
;; the UIDs in known-uid-set, in ascending order.
;; * is not allowed.
known-uid-set = sequence-set
;; Set of UIDs corresponding to the messages in
;; known-sequence-set, in ascending order.
;; * is not allowed.
message-data =/ expunged-resp
expunged-resp = "VANISHED" [SP "(EARLIER)"] SP known-uids
; Melnikov & Cridland Standards Track [Page 47]
; RFC 7162 IMAP CONDSTORE & QRESYNC May 2014
rexpunges-fetch-mod = "VANISHED"
;; VANISHED UID FETCH modifier conforms
;; to the fetch-modifier syntax
;; defined in [RFC4466]. It is only
;; allowed in the UID FETCH command.
resp-text-code =/ "CLOSED"
; ############################################################################
; Melnikov & Cridland Standards Track [Page 4]
; RFC 4731 IMAP4 Extension to SEARCH November 2006
;
; ...
;
; 4. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF].
;
; Non-terminals referenced but not defined below are as defined by
; [IMAP4], [CONDSTORE], or [IMAPABNF].
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lowercase characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
capability =/ "ESEARCH"
search-return-data = "MIN" SP nz-number /
"MAX" SP nz-number /
"ALL" SP sequence-set /
"COUNT" SP number
;; conforms to the generic
;; search-return-data syntax defined
;; in [IMAPABNF]
search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT"
;; conforms to generic search-return-opt
;; syntax defined in [IMAPABNF]
; When the CONDSTORE [CONDSTORE] IMAP extension is also supported,
; the ABNF is updated as follows:
search-return-data =/ "MODSEQ" SP mod-sequence-value
;; mod-sequence-value is defined
;; in [CONDSTORE]
; ############################################################################
; Siemborski & Gulbrandsen Standards Track [Page 4]
; RFC 4959 IMAP Ext for SASL Initial Client Response September 2007
;
;
; 7. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form [RFC4234] notation. [RFC3501] defines the non-terminals
; capability, auth-type, and base64.
capability =/ "SASL-IR"
authenticate = "AUTHENTICATE" SP auth-type [SP (base64 / "=")]
*(CRLF base64)
;;redefine AUTHENTICATE from [RFC3501]
; ############################################################################
; Gulbrandsen Standards Track [Page 5]
; RFC 4978 The IMAP COMPRESS Extension August 2007
;
; ...
;
; 5. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC4234]. This syntax augments
; the grammar specified in [RFC3501]. [RFC4234] defines SP and
; [RFC3501] defines command-auth, capability, and resp-text-code.
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lower case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
command-auth =/ compress
compress = "COMPRESS" SP algorithm
capability =/ "COMPRESS=" algorithm
;; multiple COMPRESS capabilities allowed
algorithm = "DEFLATE"
resp-text-code =/ "COMPRESSIONACTIVE"
; Note that due the syntax of capability names, future algorithm names
; must be atoms.
; ############################################################################
; Burger Standards Track [Page 1]
; RFC 5032 Search Within September 2007
;
; ...
;
; 3. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation. Elements not defined here can be found in the
; formal syntax of ABNF [RFC4234] and IMAP [RFC3501].
;
; This document extends RFC 3501 [RFC3501] with two new search keys:
; OLDER <interval> and YOUNGER <interval>.
search-key =/ ( "OLDER" / "YOUNGER" ) SP nz-number
; search-key defined in RFC 3501
; ############################################################################
; Gulbrandsen & Melnikov Standards Track [Page 3]
; RFC 5161 The IMAP ENABLE Extension March 2008
;
; ...
;
; 4. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC5234] including the core
; rules in Appendix B.1. [RFC3501] defines the non-terminals
; "capability" and "command-any".
;
; Except as noted otherwise, all alphabetic characters are
; case-insensitive. The use of upper or lower case characters to
; define token strings is for editorial clarity only. Implementations
; MUST accept these strings in a case-insensitive fashion.
capability =/ "ENABLE"
command-any =/ "ENABLE" 1*(SP capability)
response-data =/ "*" SP enable-data CRLF
enable-data = "ENABLED" *(SP capability)
; ############################################################################
; Melnikov Standards Track [Page 9]
; RFC 5182 Last SEARCH Result Reference March 2008
;
;
; 3. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF]. Non-terminals
; referenced but not defined below are as defined in [IMAP4] or
; [IMAPABNF].
;
; Except as noted otherwise, all alphabetic characters are
; case-insensitive. The use of upper- or lower-case characters to
; define token strings is for editorial clarity only. Implementations
; MUST accept these strings in a case-insensitive fashion.
capability =/ "SEARCHRES"
;; capability is defined in [IMAP4]
sequence-set =/ seq-last-command
;; extends sequence-set to allow for
;; "result of the last command" indicator.
seq-last-command = "$"
search-return-opt = "SAVE"
;; conforms to generic search-return-opt
;; syntax defined in [IMAPABNF]
resp-text-code =/ "NOTSAVED"
;; <resp-text-code> from [IMAP4]
; ############################################################################
; Newman, et al. Standards Track [Page 7]
; RFC 5255 IMAP Internationalization June 2008
;
;
; 3.5. Formal Syntax
;
; The following syntax specification inherits ABNF [RFC5234] rules from
; IMAP4rev1 [RFC3501], IMAP4 Namespace [RFC2342], Tags for the
; Identifying Languages [RFC4646], UTF-8 [RFC3629], and Collected
; Extensions to IMAP4 ABNF [RFC4466].
command-any =/ language-cmd
; LANGUAGE command is valid in all states
language-cmd = "LANGUAGE" *(SP lang-range-quoted)
response-payload =/ language-data
language-data = "LANGUAGE" SP "(" lang-tag-quoted *(SP
lang-tag-quoted) ")"
namespace-trans = SP DQUOTE "TRANSLATION" DQUOTE SP "(" string ")"
; the string is encoded in Modified UTF-7.
; this is a subset of the syntax permitted by
; the Namespace-Response-Extension rule in [RFC4466]
lang-range-quoted = astring
; Once any literal wrapper or quoting is removed, this
; follows the language-range rule in [RFC4647]
lang-tag-quoted = astring
; Once any literal wrapper or quoting is removed, this follows
; the Language-Tag rule in [RFC4646]
resp-text = ["[" resp-text-code "]" SP ] UTF8-TEXT-CHAR
*(UTF8-TEXT-CHAR / "[")
; After the server is changed to a language other than
; i-default, this resp-text rule replaces the resp-text
; rule from [RFC3501].
UTF8-TEXT-CHAR = %x20-5A / %x5C-7E / UTF8-2 / UTF8-3 / UTF8-4
; UTF-8 excluding 7-bit control characters and "["
; ...
;
; Newman, et al. Standards Track [Page 13]
; RFC 5255 IMAP Internationalization June 2008
;
; ...
;
; 4.10. Formal Syntax
;
; The following syntax specification inherits ABNF [RFC5234] rules from
; IMAP4rev1 [RFC3501] and the Internet Application Protocol Comparator
; Registry [RFC4790].
command-auth =/ comparator-cmd
resp-text-code =/ "BADCOMPARATOR"
comparator-cmd = "COMPARATOR" *(SP comp-order-quoted)
response-payload =/ comparator-data
comparator-data = "COMPARATOR" SP comp-sel-quoted [SP "("
comp-id-quoted *(SP comp-id-quoted) ")"]
comp-id-quoted = astring
; Once any literal wrapper or quoting is removed, this
; follows the collation-id rule from [RFC4790]
comp-order-quoted = astring
; Once any literal wrapper or quoting is removed, this
; follows the collation-order rule from [RFC4790]
; Newman, et al. Standards Track [Page 14]
; RFC 5255 IMAP Internationalization June 2008
comp-sel-quoted = astring
; Once any literal wrapper or quoting is removed, this
; follows the collation-selected rule from [RFC4790]
; ############################################################################
; RFC 5255 Errata
; Source of RFC: imapext (app)
;
; Errata ID: 4092
; Status: Verified
; Type: Technical
; Publication Format(s) : TEXT
; Reported By: Chris Newman
; Date Reported: 2014-08-26
; Verifier Name: Barry Leiba
; Date Verified: 2014-08-26
;
; Section 3.5 says:
lang-range-quoted = astring
; Once any literal wrapper or quoting is removed, this
; follows the language-range rule in [RFC4647]
; It should say:
lang-range-quoted = astring
; Once any literal wrapper or quoting is removed, this
; follows the language-range rule in [RFC4647],
; or is the 7-character string "default"
; Notes:
;
; This change makes the ABNF comment match the prose and example in section 3.2.
; ############################################################################
; Crispin & Murchison Standards Track [Page 13]
; RFC 5256 IMAP Sort June 2008
;
; ...
;
; 5. Formal Syntax of SORT and THREAD Commands and Responses
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF]. It also uses [ABNF]
; rules defined in [IMAP].
sort = ["UID" SP] "SORT" SP sort-criteria SP search-criteria
sort-criteria = "(" sort-criterion *(SP sort-criterion) ")"
sort-criterion = ["REVERSE" SP] sort-key
sort-key = "ARRIVAL" / "CC" / "DATE" / "FROM" / "SIZE" /
"SUBJECT" / "TO"
thread = ["UID" SP] "THREAD" SP thread-alg SP search-criteria
thread-alg = "ORDEREDSUBJECT" / "REFERENCES" / thread-alg-ext
thread-alg-ext = atom
; New algorithms MUST be registered with IANA
search-criteria = charset 1*(SP search-key)
charset = atom / quoted
; CHARSET values MUST be registered with IANA
sort-data = "SORT" *(SP nz-number)
thread-data = "THREAD" [SP 1*thread-list]
; Crispin & Murchison Standards Track [Page 14]
; RFC 5256 IMAP Sort June 2008
thread-list = "(" (thread-members / thread-nested) ")"
thread-members = nz-number *(SP nz-number) [SP thread-nested]
thread-nested = 2*thread-list
; The following syntax describes base subject extraction rules (2)-(6):
subject = *subj-leader [subj-middle] *subj-trailer
subj-refwd = ("re" / ("fw" ["d"])) *WSP [subj-blob] ":"
subj-blob = "[" *BLOBCHAR "]" *WSP
subj-fwd = subj-fwd-hdr subject subj-fwd-trl
subj-fwd-hdr = "[fwd:"
subj-fwd-trl = "]"
subj-leader = (*subj-blob subj-refwd) / WSP
subj-middle = *subj-blob (subj-base / subj-fwd)
; last subj-blob is subj-base if subj-base would
; otherwise be empty
subj-trailer = "(fwd)" / WSP
subj-base = NONWSP *(*WSP NONWSP)
; can be a subj-blob
BLOBCHAR = %x01-5a / %x5c / %x5e-ff
; any CHAR8 except '[' and ']'.
; SHOULD comply with [UTF-8]
NONWSP = %x01-08 / %x0a-1f / %x21-ff
; any CHAR8 other than WSP.
; SHOULD comply with [UTF-8]
; ############################################################################
; Leiba & Melnikov Standards Track [Page 18]
; RFC 5258 IMAP4 LIST Command Extensions June 2008
;
; ...
;
; 6. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) as described in [ABNF]. Terms not defined here are taken
; from [IMAP4]. In particular, note that the version of "mailbox-list"
; below, which defines the payload of the LIST response, updates the
; version defined in the IMAP specification. It is pointed to by
; "mailbox-data", which is defined in [IMAP4].
;
; "vendor-token" is defined in [ACAP]. Note that this normative
; reference to ACAP will be an issue in moving this spec forward, since
; it introduces a dependency on ACAP. The definitions of
; "vendor-token" and of the IANA registry must eventually go somewhere
; else, in a document that can be moved forward on the standards track
; independently of ACAP.
;
;
; Leiba & Melnikov Standards Track [Page 19]
; RFC 5258 IMAP4 LIST Command Extensions June 2008
childinfo-extended-item = "CHILDINFO" SP "("
list-select-base-opt-quoted
*(SP list-select-base-opt-quoted) ")"
; Extended data item (mbox-list-extended-item)
; returned when the RECURSIVEMATCH
; selection option is specified.
; Note 1: the CHILDINFO tag can be returned
; with and without surrounding quotes, as per
; mbox-list-extended-item-tag production.
; Note 2: The selection options are always returned
; quoted, unlike their specification in
; the extended LIST command.
child-mbox-flag = "\HasChildren" / "\HasNoChildren"
; attributes for CHILDREN return option, at most one
; possible per LIST response
eitem-standard-tag = atom
; a tag for extended list data defined in a Standard
; Track or Experimental RFC.
eitem-vendor-tag = vendor-token "-" atom
; a vendor-specific tag for extended list data
list = "LIST" [SP list-select-opts] SP mailbox SP mbox-or-pat
[SP list-return-opts]
list-return-opts = "RETURN" SP
"(" [return-option *(SP return-option)] ")"
; list return options, e.g., CHILDREN
list-select-base-opt = "SUBSCRIBED" / option-extension
; options that can be used by themselves
list-select-base-opt-quoted = DQUOTE list-select-base-opt DQUOTE
list-select-independent-opt = "REMOTE" / option-extension
; options that do not syntactically interact with
; other options
list-select-mod-opt = "RECURSIVEMATCH" / option-extension
; options that require a list-select-base-opt
; to also be present
list-select-opt = list-select-base-opt / list-select-independent-opt
/ list-select-mod-opt
; An option registration template is described in
; Section 9.3 of this document.
; Leiba & Melnikov Standards Track [Page 20]
; RFC 5258 IMAP4 LIST Command Extensions June 2008
list-select-opts = "(" [
(*(list-select-opt SP) list-select-base-opt
*(SP list-select-opt))
/ (list-select-independent-opt
*(SP list-select-independent-opt))
] ")"
; Any number of options may be in any order.
; If a list-select-mod-opt appears, then a
; list-select-base-opt must also appear.
; This allows these:
; ()
; (REMOTE)
; (SUBSCRIBED)
; (SUBSCRIBED REMOTE)
; (SUBSCRIBED RECURSIVEMATCH)
; (SUBSCRIBED REMOTE RECURSIVEMATCH)
; But does NOT allow these:
; (RECURSIVEMATCH)
; (REMOTE RECURSIVEMATCH)
mailbox-list = "(" [mbx-list-flags] ")" SP
(DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox
[SP mbox-list-extended]
; This is the list information pointed to by the ABNF
; item "mailbox-data", which is defined in [IMAP4]
mbox-list-extended = "(" [mbox-list-extended-item
*(SP mbox-list-extended-item)] ")"
mbox-list-extended-item = mbox-list-extended-item-tag SP
tagged-ext-val
mbox-list-extended-item-tag = astring
; The content MUST conform to either "eitem-vendor-tag"
; or "eitem-standard-tag" ABNF productions.
; A tag registration template is described in this
; document in Section 9.5.
mbx-list-oflag =/ child-mbox-flag / "\Subscribed" / "\Remote"
mbx-list-sflag =/ "\NonExistent"
mbox-or-pat = list-mailbox / patterns
option-extension = (option-standard-tag / option-vendor-tag)
[SP option-value]
; Leiba & Melnikov Standards Track [Page 21]
; RFC 5258 IMAP4 LIST Command Extensions June 2008
option-standard-tag = atom
; an option defined in a Standards Track or
; Experimental RFC
option-val-comp = astring /
option-val-comp *(SP option-val-comp) /
"(" option-val-comp ")"
option-value = "(" option-val-comp ")"
option-vendor-tag = vendor-token "-" atom
; a vendor-specific option, non-standard
patterns = "(" list-mailbox *(SP list-mailbox) ")"
return-option = "SUBSCRIBED" / "CHILDREN" / option-extension
tagged-ext-comp = astring /
tagged-ext-comp *(SP tagged-ext-comp) /
"(" tagged-ext-comp ")"
; Extensions that follow this general
; syntax should use nstring instead of
; astring when appropriate in the context
; of the extension.
; Note that a message set or a "number"
; can always be represented as an "atom".
; A URL should be represented as
; a "quoted" string.
tagged-ext-simple = sequence-set / number
tagged-ext-val = tagged-ext-simple /
"(" [tagged-ext-comp] ")"
; ############################################################################
; Melnikov & Coates Standards Track [Page 19]
; RFC 5259 IMAP CONVERT extension July 2008
;
; ...
;
; 10. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (ABNF) notation as used in [ABNF], and incorporates by reference
; the core rules defined in that document.
;
; This syntax augments the grammar specified in [RFC3501] and
; [RFC3516]. Non-terminals not defined in this document can be found
; in [RFC3501], [RFC3516], [IMAPABNF], [MIME-MTSRP], and
; [MEDIAFEAT-REG].
command-select =/ convert
uid =/ "UID" SP convert
; Unique identifiers used instead of message
; sequence numbers
convert = "CONVERT" SP sequence-set SP convert-params SP
( convert-att /
"(" convert-att *(SP convert-att) ")" )
convert-att = "UID" /
"BODYPARTSTRUCTURE" section-convert /
"BINARY" section-convert [partial] /
"BINARY.SIZE" section-convert /
"BODY[HEADER]" /
"BODY[" section-part ".HEADER]" /
"BODY[" section-part ".MIME]" /
"AVAILABLECONVERSIONS" section-convert
; <partial> is defined in [RFC3516].
; <section-part> is defined in [RFC3501].
; Melnikov & Coates Standards Track [Page 20]
; RFC 5259 IMAP CONVERT extension July 2008
convert-params = "(" (quoted-to-mime-type / default-conversion)
[SP "(" transcoding-params ")"] ")"
quoted-to-mime-type = DQUOTE to-mime-type DQUOTE
transcoding-params = transcoding-param
*(SP transcoding-param)
transcoding-param-names = transcoding-param-name
*(SP transcoding-param-name)
transcoding-param = transcoding-param-name SP
transcoding-param-value
transcoding-param-name = astring
; <transcod-param-name-nq> represented as a quoted,
; literal or atom. Note that
; <transcod-param-name-nq> allows for "%", which is
; not allowed in atoms. Such values must be
; represented as quoted or literal.
transcod-param-name-nq = Feature-tag
; <Feature-tag> is defined in [MEDIAFEAT-REG].
transcoding-param-value = astring
default-conversion = "NIL"
message-data =/ nz-number SP "CONVERTED" SP convert-correlator
SP convert-msg-attrs
convert-correlator = "(" "TAG" SP tag-string ")"
tag-string = string
; tag of the command that caused
; the CONVERTED response, sent as
; a string.
convert-msg-attrs = "(" convert-msg-att *(SP convert-msg-att) ")"
; "UID" MUST be the first data item, if present.
convert-msg-att = msg-att-semistat / msg-att-conv-static
msg-att-conv-static = "UID" SP uniqueid
; MUST NOT change for a message
; Melnikov & Coates Standards Track [Page 21]
; RFC 5259 IMAP CONVERT extension July 2008
msg-att-semistat =
( "BINARY" section-convert ["<" number ">"] SP
(nstring / literal8 / converterror-phrase) ) /
( "BINARY.SIZE" section-convert SP
(number / converterror-phrase) ) /
( "BODYPARTSTRUCTURE" section-convert SP
(body / converterror-phrase) ) /
( "AVAILABLECONVERSIONS" section-convert SP
(mimetype-list / converterror-phrase) )
; MUST NOT change during an IMAP "session",
; but not necessarily static in the long term.
section-convert = section-binary
; <section-binary> is defined in [RFC3516].
;
; Note that unlike [RFC3516], conversion
; of a top level multipart/* is allowed.
resp-text-code =/ "TEMPFAIL" /
"MAXCONVERTMESSAGES" SP nz-number /
"MAXCONVERTPARTS" SP nz-number
; <resp-text-code> is defined in [RFC3501].
mimetype-and-params = quoted-to-mime-type
[SP "(" transcoding-params ")"]
; always includes a specific MIME type
mimetype-list = "(" "(" [quoted-to-mime-type
*(SP quoted-to-mime-type)] ")" ")"
; Unordered list of MIME types. It can be empty.
;
; Two levels of parenthesis is needed to distinguish this
; data from <converterror-phrase>.
converterror-phrase = "(" "ERROR" SP
convert-err-descript SP convert-error-code ")"
convert-error-code = "TEMPFAIL" [SP nz-number]
/ bad-params
/ missing-params
convert-err-descript = string
; Human-readable text explaining the conversion error.
; The default charset is US-ASCII, unless
; the LANGUAGE command [IMAP-I18N] is called, when
; the charset changes to UTF-8.
quoted-from-mime-type = DQUOTE from-concrete-mime-type DQUOTE
; Melnikov & Coates Standards Track [Page 22]
; RFC 5259 IMAP CONVERT extension July 2008
bad-params = "BADPARAMETERS"
1*(SP (quoted-from-mime-type / nil)
SP mimetype-and-params)
; nil is only returned when the body part doesn't exist.
missing-params = "MISSINGPARAMETERS"
1*(SP quoted-from-mime-type SP
mimetype-and-missing-params)
mimetype-and-missing-params = quoted-to-mime-type
"(" transcoding-param-names ")"
; always includes a specific MIME type
concrete-mime-type = type-name "/" subtype-name
; i.e., "type/subtype".
; type-name and subtype-name
; are defined in [MIME-MTSRP].
from-concrete-mime-type = concrete-mime-type
to-mime-type = concrete-mime-type
command-auth =/ conversions-cmd
conversions-cmd = "CONVERSIONS" SP from-mime-type-req SP
to-mime-type-req
from-mime-type-req = astring
; "mime-type-req" represented as IMAP <atom>,
; <quoted> or <literal>
to-mime-type-req = astring
; <mime-type-req> represented as IMAP <atom>,
; <quoted> or <literal>.
; Note that <mime-type-req> allows for "*",
; which is not allowed in <atom>. Such values must
; be represented as <quoted> or <literal>.
any-mime-type = "*"
mime-type-req = any-mime-type /
(type-name "/" any-mime-type) /
concrete-mime-type
; '*', 'type/*' or 'type/subtype'.
; type-name is defined in [MIME-MTSRP].
response-payload =/ conversion-data
; Melnikov & Coates Standards Track [Page 23]
; RFC 5259 IMAP CONVERT extension July 2008
conversion-data = "CONVERSION" SP quoted-from-mime-type SP
quoted-to-mime-type
[SP "(" transcoding-param-name
*(SP transcoding-param-name) ")"]
; ############################################################################
; Cridland & King Standards Track [Page 11]
; RFC 5267 IMAP CONTEXT July 2008
;
;
; 5. Formal Syntax
;
; The collected formal syntax. This uses ABNF as defined in [ABNF].
; It includes definitions from [IMAP], [IMAP-ABNF], and [SORT].
capability =/ "CONTEXT=SEARCH" / "CONTEXT=SORT" / "ESORT"
;; <capability> from [IMAP]
command-select =/ "CANCELUPDATE" 1*(SP quoted)
;; <command-select> from [IMAP]
context-position = number
;; Context position may be 0 for SEARCH result additions.
;; <number> from [IMAP]
modifier-context = "CONTEXT"
modifier-partial = "PARTIAL" SP partial-range
partial-range = nz-number ":" nz-number
;; A range 500:400 is the same as 400:500.
;; This is similar to <seq-range> from [IMAP],
;; but cannot contain "*".
modifier-update = "UPDATE"
search-return-opt =/ modifier-context / modifier-partial /
modifier-update
;; All conform to <search-return-opt>, from [IMAP-ABNF]
resp-text-code =/ "NOUPDATE" SP quoted
;; <resp-text-code> from [IMAP]
ret-data-addto = "ADDTO"
SP "(" context-position SP sequence-set
*(SP context-position SP sequence-set)
")"
;; <sequence-set> from [IMAP]
ret-data-partial = "PARTIAL"
SP "(" partial-range SP partial-results ")"
;; <partial-range> is the requested range.
partial-results = sequence-set / "NIL"
;; <sequence-set> from [IMAP]
;; NIL indicates no results correspond to the requested range.
; Cridland & King Standards Track [Page 12]
; RFC 5267 IMAP CONTEXT July 2008
ret-data-removefrom = "REMOVEFROM"
SP "(" context-position SP sequence-set
*(SP context-position SP sequence-set)
")"
;; <sequence-set> from [IMAP]
search-return-data =/ ret-data-partial / ret-data-addto /
ret-data-removefrom
;; All conform to <search-return-data>, from [IMAP-ABNF]
sort =/ extended-sort
;; <sort> from [SORT]
extended-sort = ["UID" SP] "SORT" search-return-opts
SP sort-criteria SP search-criteria
;; <search-return-opts> from [IMAP-ABNF]
;; <sort-criteria> and <search-criteria> from [SORT]
; ############################################################################
; Daboo Standards Track [Page 13]
; RFC 5464 The IMAP METADATA Extension February 2009
;
; ...
;
; 5. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC5234].
;
; Non-terminals referenced but not defined below are as defined by
; [RFC3501], with the new definitions in [RFC4466] superseding those in
; [RFC3501].
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lower case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
capability =/ "METADATA" / "METADATA-SERVER"
; defines the capabilities for this extension.
command-auth =/ setmetadata / getmetadata
; adds to original IMAP command
entries = entry /
"(" entry *(SP entry) ")"
; entry specifiers
entry = astring
; slash-separated path to entry
; MUST NOT contain "*" or "%"
entry-value = entry SP value
entry-values = "(" entry-value *(SP entry-value) ")"
; Daboo Standards Track [Page 14]
; RFC 5464 The IMAP METADATA Extension February 2009
entry-list = entry *(SP entry)
; list of entries used in unsolicited
; METADATA response
getmetadata = "GETMETADATA" [SP getmetadata-options]
SP mailbox SP entries
; empty string for mailbox implies
; server annotation.
getmetadata-options = "(" getmetadata-option
*(SP getmetadata-option) ")"
getmetadata-option = tagged-ext-label [SP tagged-ext-val]
; tagged-ext-label and tagged-ext-val
; are defined in [RFC4466].
maxsize-opt = "MAXSIZE" SP number
; Used as a getmetadata-option
metadata-resp = "METADATA" SP mailbox SP
(entry-values / entry-list)
; empty string for mailbox implies
; server annotation.
response-payload =/ metadata-resp
; adds to original IMAP data responses
resp-text-code =/ "METADATA" SP "LONGENTRIES" SP number
; new response codes for GETMETADATA
resp-text-code =/ "METADATA" SP ("MAXSIZE" SP number /
"TOOMANY" / "NOPRIVATE")
; new response codes for SETMETADATA
; failures
scope-opt = "DEPTH" SP ("0" / "1" / "infinity")
; Used as a getmetadata-option
setmetadata = "SETMETADATA" SP mailbox
SP entry-values
; empty string for mailbox implies
; server annotation.
value = nstring / literal8
; ############################################################################
; Gulbrandsen, et al. Standards Track [Page 16]
; RFC 5465 IMAP NOTIFY Extension February 2009
;
;
; 8. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC5234]. [RFC3501] defines
; the non-terminals "capability", "command-auth", "mailbox", "mailbox-
; data", "resp-text-code", and "search-key". The "modifier-update"
; non-terminal is defined in [RFC5267]. "mbx-list-oflag" is defined in
; [RFC3501] and updated by [RFC5258].
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lower case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion. For example, the
; <filter-mailboxes-selected> non-terminal value "SELECTED" must be
; treated in the same way as "Selected" or "selected".
capability =/ "NOTIFY"
command-auth =/ notify
notify = "NOTIFY" SP
(notify-set / notify-none)
notify-set = "SET" [status-indicator] SP event-groups
; Replace registered notification events
; with the specified list of events
notify-none = "NONE"
; Cancel all registered notification
; events. The client is not interested
; in receiving any events.
status-indicator = SP "STATUS"
one-or-more-mailbox = mailbox / many-mailboxes
many-mailboxes = "(" mailbox *(SP mailbox) ")"
event-groups = event-group *(SP event-group)
event-group = "(" filter-mailboxes SP events ")"
;; Only <message-event>s are allowed in <events>
;; when <filter-mailboxes-selected> is used.
filter-mailboxes = filter-mailboxes-selected /
filter-mailboxes-other
; Gulbrandsen, et al. Standards Track [Page 17]
; RFC 5465 IMAP NOTIFY Extension February 2009
filter-mailboxes-other = "inboxes" / "personal" / "subscribed" /
( "subtree" SP one-or-more-mailbox ) /
( "mailboxes" SP one-or-more-mailbox )
filter-mailboxes-selected = "selected" / "selected-delayed"
;; Apply to the currently selected mailbox only.
;; Only one of them can be specified in a NOTIFY
;; command.
events = ( "(" event *(SP event) ")" ) / "NONE"
;; As in [MSGEVENT].
;; "NONE" means that the client does not wish
;; to receive any events for the specified
;; mailboxes.
event = message-event /
mailbox-event / user-event / event-ext
message-event = ( "MessageNew" [SP
"(" fetch-att *(SP fetch-att) ")" ] )
/ "MessageExpunge"
/ "FlagChange"
/ "AnnotationChange"
;; "MessageNew" includes "MessageAppend" from
;; [MSGEVENT]. "FlagChange" is any of
;; "MessageRead", "MessageTrash", "FlagsSet",
;; "FlagsClear" [MSGEVENT]. "MessageExpunge"
;; includes "MessageExpire" [MSGEVENT].
;; MessageNew and MessageExpunge MUST always
;; be specified together. If FlagChange is
;; specified, then MessageNew and MessageExpunge
;; MUST be specified as well.
;; The fett-att list may only be present for the
;; SELECTED/SELECTED-DELAYED mailbox filter
;; (<filter-mailboxes>).
mailbox-event = "MailboxName" /
"SubscriptionChange" / "MailboxMetadataChange"
; "SubscriptionChange" includes
; MailboxSubscribe and MailboxUnSubscribe.
; "MailboxName" includes MailboxCreate,
; "MailboxDelete" and "MailboxRename".
user-event = "ServerMetadataChange"
event-ext = atom
;; For future extensions
; Gulbrandsen, et al. Standards Track [Page 18]
; RFC 5465 IMAP NOTIFY Extension February 2009
oldname-extended-item = "OLDNAME" SP "(" mailbox ")"
;; Extended data item (mbox-list-extended-item)
;; returned in a LIST response when a mailbox is
;; renamed.
;; Note 1: the OLDNAME tag can be returned
;; with or without surrounding quotes, as per
;; mbox-list-extended-item-tag production.
resp-text-code =/ "NOTIFICATIONOVERFLOW" /
unsupported-events-code
message-event-name = "MessageNew" /
"MessageExpunge" / "FlagChange" /
"AnnotationChange"
event-name = message-event-name / mailbox-event /
user-event
unsupported-events-code = "BADEVENT"
SP "(" event-name *(SP event-name) ")"
modifier-update = "UPDATE"
[ "(" fetch-att *(SP fetch-att) ")" ]
mbx-list-oflag =/ "\NoAccess"
; ############################################################################
; RFC 5465 Errata
; Errata ID: 1694
; Status: Verified
; Type: Editorial
; Publication Format(s) : TEXT
; Reported By: Alfred Hoenes
; Date Reported: 2009-02-23
; Verifier Name: Alexey Melnikov
; Date Verified: 2009-07-06
;
; Section 8, pg.18 says:
message-event = ( "MessageNew" [SP
"(" fetch-att *(SP fetch-att) ")" ] )
[[...]]
;; The fett-att list may only be present for the
;; SELECTED/SELECTED-DELAYED mailbox filter
;; (<filter-mailboxes>).
; It should say:
message-event = ( "MessageNew" [SP
"(" fetch-att *(SP fetch-att) ")" ] )
[[...]]
;; The fetch-att list may only be present for the
;; SELECTED/SELECTED-DELAYED mailbox filter
;; (<filter-mailboxes>).
; Notes:
;
; Location is near bottom of page 18.
;
; Rationale: confusing typo; s/fett/fetch/
; ############################################################################
; Melnikov & King Standards Track [Page 5]
; RFC 5466 IMAP Filters February 2009
;
;
; language tag consisting of 6 Unicode characters: <U+E0001>,
; <U+E0066>, <U+E0072>, <U+E002D>, <U+E0063>, <U+E0061>.
;
; 4. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF].
;
; Non-terminals referenced but not defined below are as defined by
; [RFC3501] or [IMAPABNF].
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lower case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
capability =/ "FILTERS"
search-criteria = search-key *(SP search-key)
search-key =/ "FILTER" SP filter-name
;; New SEARCH criterion for referencing filters
filter-name = 1*<any ATOM-CHAR except "/">
;; Note that filter-name disallows UTF-8 or
;; the following characters: "(", ")", "{",
;; " ", "%", "*", "]". See definition of
;; ATOM-CHAR [RFC3501].
resp-text-code =/ "UNDEFINED-FILTER" SP filter-name
; ############################################################################
; Cridland Standards Track [Page 5]
; RFC 5524 URLFETCH Binary May 2009
;
; ...
;
; 5. Formal Syntax
;
; This formal syntax uses ABNF as specified in [ABNF], and includes
; productions defined in [URLAUTH], [BINARY], and [IMAP].
capability =/ "URLAUTH=BINARY"
; Command parameters; see Section 3.1
urlfetch = "URLFETCH" 1*(SP url-fetch-arg)
url-fetch-arg = url-fetch-simple / url-fetch-ext
url-fetch-simple = url-full
; Unextended URLFETCH.
url-fetch-ext = "(" url-full *(SP url-fetch-param) ")"
; If no url-fetch-param present, as unextended.
url-fetch-param = "BODY" / "BINARY" / "BODYPARTSTRUCTURE" / atom
; Response; see Section 3.2
urlfetch-data = "*" SP "URLFETCH"
1*(SP (urldata-simple / urldata-ext /
urldata-error))
urldata-error = SP url-full SP nil
urldata-simple = SP url-full SP nstring
; If client issues url-fetch-simple, server MUST respond with
; urldata-simple.
urldata-ext = SP url-full url-metadata
url-metadata = 1*(SP "(" url-metadata-el ")")
; Cridland Standards Track [Page 6]
; RFC 5524 URLFETCH Binary May 2009
url-metadata-el = url-meta-bodystruct / url-meta-body /
url-meta-binary
url-meta-bodystruct = "BODYPARTSTRUCTURE" SP body
url-meta-binary = "BINARY" SP ( nstring / literal8 )
; If content contains a NUL octet, literal8 MUST be used.
; Otherwise, content SHOULD use nstring.
; On decoding error, NIL should be used.
url-meta-body = "BODY" SP nstring
; ############################################################################
; Gulbrandsen Standards Track [Page 5]
; RFC 5530 IMAP Response Codes May 2009
;
; ...
;
; 4. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC5234]. [RFC3501] defines
; the non-terminal "resp-text-code".
;
; Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lowercase characters to define
; token strings is for editorial clarity only.
resp-text-code =/ "UNAVAILABLE" / "AUTHENTICATIONFAILED" /
"AUTHORIZATIONFAILED" / "EXPIRED" /
"PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" /
"INUSE" / "EXPUNGEISSUED" / "CORRUPTION" /
"SERVERBUG" / "CLIENTBUG" / "CANNOT" /
"LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" /
"NONEXISTENT"
; ############################################################################
; RFC 6855 Obsoletes RFC 5738 (2010)
;
; Resnick, et al. Standards Track [Page 2]
; RFC 6855 IMAP Support for UTF-8 March 2013
;
; ...
;
; 3. "UTF8=ACCEPT" IMAP Capability and UTF-8 in IMAP Quoted-Strings
;
; The "UTF8=ACCEPT" capability indicates that the server supports the
; ability to open mailboxes containing internationalized messages with
; the "SELECT" and "EXAMINE" commands, and the server can provide UTF-8
; responses to the "LIST" and "LSUB" commands. This capability also
; affects other IMAP extensions that can return mailbox names or their
; prefixes, such as NAMESPACE [RFC2342] and ACL [RFC4314].
;
; The "UTF8=ONLY" capability, described in Section 6, implies the
; "UTF8=ACCEPT" capability. A server is said to support "UTF8=ACCEPT"
; if it advertises either "UTF8=ACCEPT" or "UTF8=ONLY".
;
; A client MUST use the "ENABLE" command [RFC5161] with the
; "UTF8=ACCEPT" option (defined in Section 4 below) to indicate to the
; server that the client accepts UTF-8 in quoted-strings and supports
; the "UTF8=ACCEPT" extension. The "ENABLE UTF8=ACCEPT" command is
; only valid in the authenticated state.
;
; The IMAP base specification [RFC3501] forbids the use of 8-bit
; characters in atoms or quoted-strings. Thus, a UTF-8 string can only
; be sent as a literal. This can be inconvenient from a coding
; standpoint, and unless the server offers IMAP non-synchronizing
; literals [RFC2088], this requires an extra round trip for each UTF-8
; string sent by the client. When the IMAP server supports
; "UTF8=ACCEPT", it supports UTF-8 in quoted-strings with the following
; syntax:
quoted =/ DQUOTE *uQUOTED-CHAR DQUOTE
; QUOTED-CHAR is not modified, as it will affect
; other RFC 3501 ABNF non-terminals.
uQUOTED-CHAR = QUOTED-CHAR / UTF8-2 / UTF8-3 / UTF8-4
UTF8-2 = <Defined in Section 4 of RFC 3629>
UTF8-3 = <Defined in Section 4 of RFC 3629>
UTF8-4 = <Defined in Section 4 of RFC 3629>
; When this extended quoting mechanism is used by the client, the
; server MUST reject, with a "BAD" response, any octet sequences with
;
;
; Resnick, et al. Standards Track [Page 3]
; RFC 6855 IMAP Support for UTF-8 March 2013
;
;
; the high bit set that fail to comply with the formal syntax
; requirements of UTF-8 [RFC3629]. The IMAP server MUST NOT send UTF-8
; in quoted-strings to the client unless the client has indicated
; support for that syntax by using the "ENABLE UTF8=ACCEPT" command.
; ############################################################################
; Melnikov & Sirainen Standards Track [Page 3]
; IMAP4 Extension for Returning STATUS Information in Extended LIST
; RFC 5819 March 2010
;
;
; 4. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) as described in [ABNF]. Terms not defined here are taken
; from [RFC3501] and [LISTEXT].
return-option =/ status-option
status-option = "STATUS" SP "(" status-att *(SP status-att) ")"
;; This ABNF production complies with
;; <option-extension> syntax.
; ############################################################################
; Karp IMAP4 Display-Based Address Sorting [Page 2]
; RFC 5957 July 2010
;
; ...
;
; 5. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC5234]. [IMAP] defines the
; non-terminal "capability", and [SORT] defines "sort-key".
capability =/ "SORT=DISPLAY"
sort-key =/ "DISPLAYFROM" / "DISPLAYTO"
; ############################################################################
; Leiba & Nicolson Standards Track [Page 8]
; RFC 6154 IMAP LIST: Special-Use Mailboxes March 2011
;
; ...
;
; 6. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) as described in [RFC5234].
create-param =/ "USE" SP "(" [use-attr *(SP use-attr)] ")"
; Extends "create-param" from RFC 4466 [RFC4466]
mbx-list-oflag =/ use-attr
; Extends "mbx-list-oflag" from IMAP base [RFC3501]
list-select-independent-opt =/ "SPECIAL-USE"
; Extends "list-select-independent-opt" from
; LIST-extended [RFC5258]
return-option =/ "SPECIAL-USE"
; Extends "return-option" from
; LIST-extended [RFC5258]
resp-text-code =/ "USEATTR"
; Extends "resp-text-code" from
; IMAP [RFC3501]
use-attr = "\All" / "\Archive" / "\Drafts" / "\Flagged" /
"\Junk" / "\Sent" / "\Trash" / use-attr-ext
use-attr-ext = "\" atom
; Reserved for future extensions. Clients
; MUST ignore list attributes they do not understand
; Server implementations MUST NOT generate
; extension attributes except as defined by
; future Standards-Track revisions of or
; extensions to this specification.
; ############################################################################
; Sirainen Standards Track [Page 4]
; RFC 6203 IMAP4 FUZZY Search March 2011
;
; ...
;
; 7. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) as described in [ABNF]. It includes definitions from
; [RFC3501], [IMAP-ABNF], and [SORT].
capability =/ "SEARCH=FUZZY"
score = 1*3DIGIT
;; (1 <= n <= 100)
score-list = "(" [score *(SP score)] ")"
search-key =/ "FUZZY" SP search-key
search-return-data =/ "RELEVANCY" SP score-list
;; Conforms to <search-return-data>, from [IMAP-ABNF]
search-return-opt =/ "RELEVANCY"
;; Conforms to <search-return-opt>, from [IMAP-ABNF]
sort-key =/ "RELEVANCY"
; ############################################################################
; Gulbrandsen & Freed Standards Track [Page 5]
; RFC 6851 IMAP - MOVE Extension January 2013
;
; ...
;
; 5. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC5234]. [RFC3501] defines
; the non-terminals "capability", "command-select", "sequence-set", and
; "mailbox".
;
; Except as noted otherwise, all alphabetic characters are case
; insensitive. The use of upper or lower case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
capability =/ "MOVE"
command-select =/ move
move = "MOVE" SP sequence-set SP mailbox
uid = "UID" SP (copy / fetch / search / store / move)
; ############################################################################
; Leiba & Melnikov Standards Track [Page 7]
; RFC 7377 IMAP4 Multimailbox SEARCH Extension October 2014
;
; ...
;
; 4. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) as described in [RFC5234]. Terms not defined here are
; taken from [RFC3501], [RFC5465], or [RFC4466].
command-auth =/ esearch
; Update definition from IMAP base [RFC3501].
; Add new "esearch" command.
command-select =/ esearch
; Update definition from IMAP base [RFC3501].
; Add new "esearch" command.
filter-mailboxes-other =/ ("subtree-one" SP one-or-more-mailbox)
; Update definition from IMAP Notify [RFC5465].
; Add new "subtree-one" selector.
filter-mailboxes-selected = "selected"
; Update definition from IMAP Notify [RFC5465].
; We forbid the use of "selected-delayed".
one-correlator = ("TAG" SP tag-string) / ("MAILBOX" SP astring) /
("UIDVALIDITY" SP nz-number)
; Each correlator MUST appear exactly once.
scope-option = scope-option-name [SP scope-option-value]
; No options defined here. Syntax for future extensions.
scope-option-name = tagged-ext-label
; No options defined here. Syntax for future extensions.
; Leiba & Melnikov Standards Track [Page 8]
; RFC 7377 IMAP4 Multimailbox SEARCH Extension October 2014
scope-option-value = tagged-ext-val
; No options defined here. Syntax for future extensions.
scope-options = scope-option *(SP scope-option)
; A given option may only appear once.
; No options defined here. Syntax for future extensions.
esearch = "ESEARCH" [SP esearch-source-opts]
[SP search-return-opts] SP search-program
search-correlator = SP "(" one-correlator *(SP one-correlator) ")"
; Updates definition in IMAP4 ABNF [RFC4466].
esearch-source-opts = "IN" SP "(" source-mbox [SP
"(" scope-options ")"] ")"
source-mbox = filter-mailboxes *(SP filter-mailboxes)
; "filter-mailboxes" is defined in IMAP Notify [RFC5465].
; See updated definition of filter-mailboxes-other, above.
; See updated definition of filter-mailboxes-selected, above.
; ############################################################################
; SrimushnamB. & Bisht Standards Track [Page 4]
; RFC 7889 The IMAP APPENDLIMIT Extension May 2016
;
; ...
;
; 5. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC5234] including the core
; rules in Appendix B.1 of that document. [RFC3501] defines the non-
; terminals "capability" and "status-att", and [RFC4466] defines
; "status-att-val".
;
; All alphabetic characters are case insensitive. The use of uppercase
; or lowercase characters to define token strings is for editorial
; clarity only. Implementations MUST accept these strings in a case-
; insensitive fashion.
capability =/ "APPENDLIMIT" ["=" number]
;; capability is defined in RFC 3501
status-att =/ "APPENDLIMIT"
;; status-att is defined in RFC 3501
status-att-val =/ "APPENDLIMIT" SP (number / nil)
;; status-att-val is defined in RFC 4466
; The number indicates the fixed maximum message size in octets that
; the server will accept. An APPENDLIMIT number of 0 indicates the
; server will not accept any APPEND commands at all for the affected
; mailboxes.
; ############################################################################
; Newman Standards Track [Page 6]
; RFC 8437 IMAP UNAUTHENTICATE for Connection Reuse August 2018
;
; ...
;
; 6. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF), as described in [RFC5234]. Amended terms are defined in
; [RFC3501].
capability =/ "UNAUTHENTICATE"
command-auth =/ "UNAUTHENTICATE"
command-select =/ "UNAUTHENTICATE"
; ############################################################################
; Bosch Standards Track [Page 4]
; RFC 8438 IMAP STATUS=SIZE Extension August 2018
;
;
; 4. Formal Syntax
;
; The following syntax specification augments the grammar specified in
; [IMAP4rev1] and [IMAP4-ABNF]. It uses the Augmented Backus-Naur Form
; (ABNF) notation as specified in [ABNF]. Elements not defined here
; are taken from [IMAP4rev1] and [IMAP4-ABNF].
capability =/ "STATUS=SIZE"
status-att =/ "SIZE"
status-att-val =/ "SIZE" SP number64
number64 = 1*DIGIT
; Unsigned 63-bit integer
; (0 <= n <= 9,223,372,036,854,775,807)
; ############################################################################
; Murchison & Gondwana Standards Track [Page 3]
; RFC 8440 IMAP LIST-MYRIGHTS August 2018
;
;
; 5. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) as described in [RFC5234]. Terms not defined here are
; taken from [RFC5258].
return-option =/ "MYRIGHTS"
; ############################################################################
; Leiba Standards Track [Page 3]
; RFC 8457 IMAP "Important" Keyword and Attribute September 2018
;
;
; 3.1. Formal Syntax
;
; The following syntax specification adds to the one in Section 6 of
; [RFC6154] using Augmented Backus-Naur Form (ABNF) as described in
; [RFC5234]. Be sure to see the ABNF notes at the beginning of
; Section 9 of [RFC3501].
use-attr =/ "\Important"
; ############################################################################
; Gondwana Standards Track [Page 8]
; RFC 8474 IMAP ObjectID September 2018
;
; ...
;
; 7. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) [RFC5234] notation. Elements not defined here can be
; found in the formal syntax of the ABNF [RFC5234], IMAP [RFC3501], and
; IMAP ABNF extensions [RFC4466] specifications.
;
; Except as noted otherwise, all alphabetic characters are case
; insensitive. The use of uppercase or lowercase characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
;
; Please note specifically that ObjectID values are case sensitive.
;
;
; Gondwana Standards Track [Page 9]
; RFC 8474 IMAP ObjectID September 2018
capability =/ "OBJECTID"
fetch-att =/ "EMAILID" / "THREADID"
fetch-emailid-resp = "EMAILID" SP "(" objectid ")"
; follows tagged-ext production from [RFC4466]
fetch-threadid-resp = "THREADID" SP ( "(" objectid ")" / nil )
; follows tagged-ext production from [RFC4466]
msg-att-static =/ fetch-emailid-resp / fetch-threadid-resp
objectid = 1*255(ALPHA / DIGIT / "_" / "-")
; characters in object identifiers are case
; significant
resp-text-code =/ "MAILBOXID" SP "(" objectid ")"
; incorporated before the expansion rule of
; atom [SP 1*<any TEXT-CHAR except "]">]
; that appears in [RFC3501]
search-key =/ "EMAILID" SP objectid / "THREADID" SP objectid
status-att =/ "MAILBOXID"
status-att-val =/ "MAILBOXID" SP "(" objectid ")"
; follows tagged-ext production from [RFC4466]
; ############################################################################
; Brandt Standards Track [Page 8]
; RFC 8508 IMAP REPLACE Extension January 2019
;
; 5. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [RFC5234]. [RFC3501] defines
; the non-terminals "capability","command-select", "mailbox",
; "seq-number", and "uid". [RFC4466] defines the non-terminal
; "append-message".
;
; Except as noted otherwise, all alphabetic characters are case
; insensitive. The use of uppercase or lowercase characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
capability =/ "REPLACE"
command-select =/ replace
replace = "REPLACE" SP seq-number SP mailbox append-message
uid =/ "UID" SP replace
; ############################################################################
; Bosch Standards Track [Page 4]
; RFC 8514 IMAP - SAVEDATE Extension January 2019
;
; ...
;
; 5. Formal Syntax
;
; The following syntax specification augments the grammar specified in
; [IMAP4rev1]. It uses the Augmented Backus-Naur Form (ABNF) notation
; as specified in [ABNF]. Elements not defined here are taken from
; [IMAP4rev1].
capability =/ "SAVEDATE"
fetch-att =/ "SAVEDATE"
msg-att-static =/ "SAVEDATE" SP (date-time / nil)
search-key =/ "SAVEDBEFORE" SP date /
"SAVEDON" SP date /
"SAVEDSINCE" SP date /
"SAVEDATESUPPORTED"
; ############################################################################
; https://www.ietf.org/archive/id/draft-ietf-extra-imap-fetch-preview-10.txt
;
; Internet Engineering Task Force (IETF) M. Slusarz
; Request for Comments: 8970 Open-Xchange Inc.
; Category: Standards Track December 2020
; ISSN: 2070-1721
;
; IMAP4 Extension: Message Preview Generation
; ...
;
; 6. Formal Syntax
;
; The following syntax specification uses the augmented Backus-Naur
; Form (BNF) as described in ABNF [RFC5234]. It includes definitions
; from IMAP [RFC3501].
capability =/ "PREVIEW"
fetch-att =/ "PREVIEW" [SP "(" preview-mod *(SP
preview-mod) ")"]
msg-att-dynamic =/ "PREVIEW" SP nstring
preview-mod = "LAZY"
; ############################################################################
; https://www.ietf.org/archive/id/draft-ietf-extra-imap4rev2-21.txt
;
; Melnikov & Leiba Expires May 27, 2021 [Page 124]
; Internet-Draft IMAP4rev2 November 2020
;
; ...
;
; 9. Formal Syntax
;
; The following syntax specification uses the Augmented Backus-Naur
; Form (ABNF) notation as specified in [ABNF].
;
;
; Melnikov & Leiba Expires May 27, 2021 [Page 125]
; Internet-Draft IMAP4rev2 November 2020
;
;
; In the case of alternative or optional rules in which a later rule
; overlaps an earlier rule, the rule which is listed earlier MUST take
; priority. For example, "\Seen" when parsed as a flag is the \Seen
; flag name and not a flag-extension, even though "\Seen" can be parsed
; as a flag-extension. Some, but not all, instances of this rule are
; noted below.
;
; Note: [ABNF] rules MUST be followed strictly; in particular:
;
; (1) Except as noted otherwise, all alphabetic characters are case-
; insensitive. The use of upper or lower case characters to define
; token strings is for editorial clarity only. Implementations MUST
; accept these strings in a case-insensitive fashion.
;
; (2) In all cases, SP refers to exactly one space. It is NOT
; permitted to substitute TAB, insert additional spaces, or
; otherwise treat SP as being equivalent to LWSP.
;
; (3) The ASCII NUL character, %x00, MUST NOT be used at any time.
address = "(" addr-name SP addr-adl SP addr-mailbox SP
addr-host ")"
addr-adl = nstring
; Holds route from [RFC-5322] obs-route if
; non-NIL
addr-host = nstring
; NIL indicates [RFC-5322] group syntax.
; Otherwise, holds [RFC-5322] domain name
addr-mailbox = nstring
; NIL indicates end of [RFC-5322] group; if
; non-NIL and addr-host is NIL, holds
; [RFC-5322] group name.
; Otherwise, holds [RFC-5322] local-part
; after removing [RFC-5322] quoting
addr-name = nstring
; If non-NIL, holds phrase from [RFC-5322]
; mailbox after removing [RFC-5322] quoting
append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP
literal
append-uid = uniqueid
astring = 1*ASTRING-CHAR / string
; Melnikov & Leiba Expires May 27, 2021 [Page 126]
; Internet-Draft IMAP4rev2 November 2020
ASTRING-CHAR = ATOM-CHAR / resp-specials
atom = 1*ATOM-CHAR
ATOM-CHAR = <any CHAR except atom-specials>
atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards /
quoted-specials / resp-specials
authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp]
*(CRLF base64)
auth-type = atom
; Defined by [SASL]
base64 = *(4base64-char) [base64-terminal]
base64-char = ALPHA / DIGIT / "+" / "/"
; Case-sensitive
base64-terminal = (2base64-char "==") / (3base64-char "=")
body = "(" (body-type-1part / body-type-mpart) ")"
body-extension = nstring / number / number64 /
"(" body-extension *(SP body-extension) ")"
; Future expansion. Client implementations
; MUST accept body-extension fields. Server
; implementations MUST NOT generate
; body-extension fields except as defined by
; future standard or standards-track
; revisions of this specification.
body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang
[SP body-fld-loc *(SP body-extension)]]]
; MUST NOT be returned on non-extensible
; "BODY" fetch
body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang
[SP body-fld-loc *(SP body-extension)]]]
; MUST NOT be returned on non-extensible
; "BODY" fetch
body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP
body-fld-enc SP body-fld-octets
body-fld-desc = nstring
; Melnikov & Leiba Expires May 27, 2021 [Page 127]
; Internet-Draft IMAP4rev2 November 2020
body-fld-dsp = "(" string SP body-fld-param ")" / nil
body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/
"QUOTED-PRINTABLE") DQUOTE) / string
; Content-Transfer-Encoding header field value.
; Defaults to "7BIT" (as per RFC 2045)
; if not present in the body part.
body-fld-id = nstring
body-fld-lang = nstring / "(" string *(SP string) ")"
body-fld-loc = nstring
body-fld-lines = number64
body-fld-md5 = nstring
body-fld-octets = number
body-fld-param = "(" string SP string *(SP string SP string) ")" / nil
body-type-1part = (body-type-basic / body-type-msg / body-type-text)
[SP body-ext-1part]
body-type-basic = media-basic SP body-fields
; MESSAGE subtype MUST NOT be "RFC822" or "GLOBAL"
body-type-mpart = 1*body SP media-subtype
[SP body-ext-mpart]
; MULTIPART body part
body-type-msg = media-message SP body-fields SP envelope
SP body SP body-fld-lines
body-type-text = media-text SP body-fields SP body-fld-lines
capability = ("AUTH=" auth-type) / atom
; New capabilities MUST begin with "X" or be
; registered with IANA in
; a standards-track, an experimental
; or an informational RFC.
capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2"
*(SP capability)
; Servers MUST implement the STARTTLS, AUTH=PLAIN,
; and LOGINDISABLED capabilities.
; Servers which offer RFC 1730 compatibility MUST
; list "IMAP4" as the first capability.
; Servers which offer RFC 3501 compatibility MUST
; list "IMAP4rev1" as one of capabilities.
; Melnikov & Leiba Expires May 27, 2021 [Page 128]
; Internet-Draft IMAP4rev2 November 2020
CHAR = <defined in [ABNF]>
CHAR8 = %x01-ff
; any OCTET except NUL, %x00
charset = atom / quoted
childinfo-extended-item = "CHILDINFO" SP "("
list-select-base-opt-quoted
*(SP list-select-base-opt-quoted) ")"
; Extended data item (mbox-list-extended-item)
; returned when the RECURSIVEMATCH
; selection option is specified.
; Note 1: the CHILDINFO extended data item tag can be
; returned with and without surrounding quotes, as per
; mbox-list-extended-item-tag production.
; Note 2: The selection options are always returned
; quoted, unlike their specification in
; the extended LIST command.
child-mbox-flag = "\HasChildren" / "\HasNoChildren"
; attributes for CHILDREN return option, at most one
; possible per LIST response
command = tag SP (command-any / command-auth / command-nonauth /
command-select) CRLF
; Modal based on state
command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / enable / x-command
; Valid in all states
command-auth = append / create / delete / examine / list /
Namespace-Command /
rename / select / status / subscribe / unsubscribe /
idle
; Valid only in Authenticated or Selected state
command-nonauth = login / authenticate / "STARTTLS"
; Valid only when in Not Authenticated state
command-select = "CLOSE" / "UNSELECT" / "EXPUNGE" / copy /
move / fetch / store / search / uid
; Valid only when in Selected state
; Melnikov & Leiba Expires May 27, 2021 [Page 129]
; Internet-Draft IMAP4rev2 November 2020
continue-req = "+" SP (resp-text / base64) CRLF
copy = "COPY" SP sequence-set SP mailbox
create = "CREATE" SP mailbox
; Use of INBOX gives a NO error
date = date-text / DQUOTE date-text DQUOTE
date-day = 1*2DIGIT
; Day of month
date-day-fixed = (SP DIGIT) / 2DIGIT
; Fixed-format version of date-day
date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
"Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
date-text = date-day "-" date-month "-" date-year
date-year = 4DIGIT
date-time = DQUOTE date-day-fixed "-" date-month "-" date-year
SP time SP zone DQUOTE
delete = "DELETE" SP mailbox
; Use of INBOX gives a NO error
digit-nz = %x31-39
; 1-9
eitem-standard-tag = atom
; a tag for LIST extended data item defined in a Standard
; Track or Experimental RFC.
eitem-vendor-tag = vendor-token "-" atom
; a vendor-specific tag for LIST extended data item
enable = "ENABLE" 1*(SP capability)
enable-data = "ENABLED" *(SP capability)
envelope = "(" env-date SP env-subject SP env-from SP
env-sender SP env-reply-to SP env-to SP env-cc SP
env-bcc SP env-in-reply-to SP env-message-id ")"
env-bcc = "(" 1*address ")" / nil
; Melnikov & Leiba Expires May 27, 2021 [Page 130]
; Internet-Draft IMAP4rev2 November 2020
env-cc = "(" 1*address ")" / nil
env-date = nstring
env-from = "(" 1*address ")" / nil
env-in-reply-to = nstring
env-message-id = nstring
env-reply-to = "(" 1*address ")" / nil
env-sender = "(" 1*address ")" / nil
env-subject = nstring
env-to = "(" 1*address ")" / nil
esearch-response = "ESEARCH" [search-correlator] [SP "UID"]
*(SP search-return-data)
; ESEARCH response replaces SEARCH response
; from IMAP4rev1.
examine = "EXAMINE" SP mailbox
fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" /
fetch-att / "(" fetch-att *(SP fetch-att) ")")
fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" /
"RFC822.SIZE" /
"BODY" ["STRUCTURE"] / "UID" /
"BODY" section [partial] /
"BODY.PEEK" section [partial] /
"BINARY" [".PEEK"] section-binary [partial] /
"BINARY.SIZE" section-binary
flag = "\Answered" / "\Flagged" / "\Deleted" /
"\Seen" / "\Draft" / flag-keyword / flag-extension
; Does not include "\Recent"
flag-extension = "\" atom
; Future expansion. Client implementations
; MUST accept flag-extension flags. Server
; implementations MUST NOT generate
; flag-extension flags except as defined by
; future standard or standards-track
; revisions of this specification.
; "\Recent" was defined in RFC 3501
; and is now deprecated.
; Melnikov & Leiba Expires May 27, 2021 [Page 131]
; Internet-Draft IMAP4rev2 November 2020
flag-fetch = flag
flag-keyword = "$MDNSent" / "$Forwarded" / "$Junk" /
"$NotJunk" / "$Phishing" / atom
flag-list = "(" [flag *(SP flag)] ")"
flag-perm = flag / "\*"
greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF
header-fld-name = astring
header-list = "(" header-fld-name *(SP header-fld-name) ")"
idle = "IDLE" CRLF "DONE"
initial-resp = (base64 / "=")
; "initial response" defined in
; Section 5.1 of [RFC4422]
list = "LIST" [SP list-select-opts] SP mailbox SP mbox-or-pat
[SP list-return-opts]
list-mailbox = 1*list-char / string
list-char = ATOM-CHAR / list-wildcards / resp-specials
list-return-opts = "RETURN" SP
"(" [return-option *(SP return-option)] ")"
; list return options, e.g., CHILDREN
list-select-base-opt = "SUBSCRIBED" / option-extension
; options that can be used by themselves
list-select-base-opt-quoted = DQUOTE list-select-base-opt DQUOTE
list-select-independent-opt = "REMOTE" / option-extension
; options that do not syntactically interact with
; other options
list-select-mod-opt = "RECURSIVEMATCH" / option-extension
; options that require a list-select-base-opt
; to also be present
; Melnikov & Leiba Expires May 27, 2021 [Page 132]
; Internet-Draft IMAP4rev2 November 2020
list-select-opt = list-select-base-opt / list-select-independent-opt
/ list-select-mod-opt
; An option registration template is described in
; Section 9.3 of this document.
list-select-opts = "(" [
(*(list-select-opt SP) list-select-base-opt
*(SP list-select-opt))
/ (list-select-independent-opt
*(SP list-select-independent-opt))
] ")"
; Any number of options may be in any order.
; If a list-select-mod-opt appears, then a
; list-select-base-opt must also appear.
; This allows these:
; ()
; (REMOTE)
; (SUBSCRIBED)
; (SUBSCRIBED REMOTE)
; (SUBSCRIBED RECURSIVEMATCH)
; (SUBSCRIBED REMOTE RECURSIVEMATCH)
; But does NOT allow these:
; (RECURSIVEMATCH)
; (REMOTE RECURSIVEMATCH)
list-wildcards = "%" / "*"
literal = "{" number64 ["+"] "}" CRLF *CHAR8
; <number64> represents the number of CHAR8s.
; A non-synchronizing literal is distinguished from
; a synchronizing literal by presence of the "+"
; before the closing "}".
; Non synchronizing literals are not allowed when
; sent from server to the client.
literal8 = "~{" number64 "}" CRLF *OCTET
; <number64> represents the number of OCTETs
; in the response string.
login = "LOGIN" SP userid SP password
mailbox = "INBOX" / astring
; INBOX is case-insensitive. All case variants of
; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX
; not as an astring. An astring which consists of
; the case-insensitive sequence "I" "N" "B" "O" "X"
; is considered to be INBOX and not an astring.
; Refer to section 5.1 for further
; semantic details of mailbox names.
; Melnikov & Leiba Expires May 27, 2021 [Page 133]
; Internet-Draft IMAP4rev2 November 2020
mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list /
esearch-response /
"STATUS" SP mailbox SP "(" [status-att-list] ")" /
number SP "EXISTS" / Namespace-Response
mailbox-list = "(" [mbx-list-flags] ")" SP
(DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox
[SP mbox-list-extended]
; This is the list information pointed to by the ABNF
; item "mailbox-data", which is defined in [IMAP4]
mbox-list-extended = "(" [mbox-list-extended-item
*(SP mbox-list-extended-item)] ")"
mbox-list-extended-item = mbox-list-extended-item-tag SP
tagged-ext-val
mbox-list-extended-item-tag = astring
; The content MUST conform to either "eitem-vendor-tag"
; or "eitem-standard-tag" ABNF productions.
mbox-or-pat = list-mailbox / patterns
mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag
*(SP mbx-list-oflag) /
mbx-list-oflag *(SP mbx-list-oflag)
mbx-list-oflag = "\Noinferiors" / child-mbox-flag /
"\Subscribed" / "\Remote" / flag-extension
; Other flags; multiple possible per LIST response
mbx-list-sflag = "\NonExistent" / "\Noselect" / "\Marked" / "\Unmarked"
; Selectability flags; only one per LIST response
media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" /
"FONT" / "MESSAGE" / "MODEL" / "VIDEO" ) DQUOTE)
/ string)
SP media-subtype
; Defined in [MIME-IMT].
; FONT defined in RFC 8081.
media-message = DQUOTE "MESSAGE" DQUOTE SP
DQUOTE ("RFC822" / "GLOBAL") DQUOTE
; Defined in [MIME-IMT]
media-subtype = string
; Defined in [MIME-IMT]
; Melnikov & Leiba Expires May 27, 2021 [Page 134]
; Internet-Draft IMAP4rev2 November 2020
media-text = DQUOTE "TEXT" DQUOTE SP media-subtype
; Defined in [MIME-IMT]
message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att))
move = "MOVE" SP sequence-set SP mailbox
msg-att = "(" (msg-att-dynamic / msg-att-static)
*(SP (msg-att-dynamic / msg-att-static)) ")"
msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")"
; MAY change for a message
msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time /
"RFC822.SIZE" SP number64 /
"BODY" ["STRUCTURE"] SP body /
"BODY" section ["<" number ">"] SP nstring /
"BINARY" section-binary SP (nstring / literal8) /
"BINARY.SIZE" section-binary SP number /
"UID" SP uniqueid
; MUST NOT change for a message
name-component = 1*UTF8-CHAR
; MUST NOT contain ".", "/", "%", or "*"
Namespace = nil / "(" 1*Namespace-Descr ")"
Namespace-Command = "NAMESPACE"
Namespace-Descr = "(" string SP
(DQUOTE QUOTED-CHAR DQUOTE / nil)
[Namespace-Response-Extensions] ")"
Namespace-Response-Extensions = *Namespace-Response-Extension
Namespace-Response-Extension = SP string SP
"(" string *(SP string) ")"
Namespace-Response = "NAMESPACE" SP Namespace
SP Namespace SP Namespace
; The first Namespace is the Personal Namespace(s).
; The second Namespace is the Other Users'
; Namespace(s).
; The third Namespace is the Shared Namespace(s).
nil = "NIL"
; Melnikov & Leiba Expires May 27, 2021 [Page 135]
; Internet-Draft IMAP4rev2 November 2020
nstring = string / nil
number = 1*DIGIT
; Unsigned 32-bit integer
; (0 <= n < 4,294,967,296)
number64 = 1*DIGIT
; Unsigned 63-bit integer
; (0 <= n <= 9,223,372,036,854,775,807)
nz-number = digit-nz *DIGIT
; Non-zero unsigned 32-bit integer
; (0 < n < 4,294,967,296)
nz-number64 = digit-nz *DIGIT
; Unsigned 63-bit integer
; (0 < n <= 9,223,372,036,854,775,807)
oldname-extended-item = "OLDNAME" SP "(" mailbox ")"
; Extended data item (mbox-list-extended-item)
; returned in a LIST response when a mailbox is
; renamed or deleted. Also returned when
; the server canonicalized the provided mailbox
; name.
; Note 1: the OLDNAME tag can be returned
; with or without surrounding quotes, as per
; mbox-list-extended-item-tag production.
option-extension = (option-standard-tag / option-vendor-tag)
[SP option-value]
option-standard-tag = atom
; an option defined in a Standards Track or
; Experimental RFC
option-val-comp = astring /
option-val-comp *(SP option-val-comp) /
"(" option-val-comp ")"
option-value = "(" option-val-comp ")"
option-vendor-tag = vendor-token "-" atom
; a vendor-specific option, non-standard
partial-range = number64 ["." nz-number64]
; Copied from RFC 5092 (IMAP URL)
; and updated to support 64bit sizes.
; Melnikov & Leiba Expires May 27, 2021 [Page 136]
; Internet-Draft IMAP4rev2 November 2020
partial = "<" number64 "." nz-number64 ">"
; Partial FETCH request. 0-based offset of
; the first octet, followed by the number of octets
; in the fragment.
password = astring
patterns = "(" list-mailbox ")"
; [RFC5258] supports multiple patterns,
; but this document only requires one
; to be supported.
; If the server is also implementing
; [RFC5258], "patterns" syntax from that
; document must be followed.
quoted = DQUOTE *QUOTED-CHAR DQUOTE
QUOTED-CHAR = <any TEXT-CHAR except quoted-specials> /
"\" quoted-specials / UTF8-2 / UTF8-3 / UTF8-4
quoted-specials = DQUOTE / "\"
rename = "RENAME" SP mailbox SP mailbox
; Use of INBOX as a destination gives a NO error
response = *(continue-req / response-data) response-done
response-data = "*" SP (resp-cond-state / resp-cond-bye /
mailbox-data / message-data / capability-data /
enable-data) CRLF
response-done = response-tagged / response-fatal
response-fatal = "*" SP resp-cond-bye CRLF
; Server closes connection immediately
response-tagged = tag SP resp-cond-state CRLF
resp-code-apnd = "APPENDUID" SP nz-number SP append-uid
resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set
resp-cond-auth = ("OK" / "PREAUTH") SP resp-text
; Authentication condition
resp-cond-bye = "BYE" SP resp-text
resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text
; Status condition
; Melnikov & Leiba Expires May 27, 2021 [Page 137]
; Internet-Draft IMAP4rev2 November 2020
resp-specials = "]"
resp-text = ["[" resp-text-code "]" SP] [text]
resp-text-code = "ALERT" /
"BADCHARSET" [SP "(" charset *(SP charset) ")" ] /
capability-data / "PARSE" /
"PERMANENTFLAGS" SP
"(" [flag-perm *(SP flag-perm)] ")" /
"READ-ONLY" / "READ-WRITE" / "TRYCREATE" /
"UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number /
resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" /
"UNAVAILABLE" / "AUTHENTICATIONFAILED" /
"AUTHORIZATIONFAILED" / "EXPIRED" /
"PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" /
"INUSE" / "EXPUNGEISSUED" / "CORRUPTION" /
"SERVERBUG" / "CLIENTBUG" / "CANNOT" /
"LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" /
"NONEXISTENT" / "NOTSAVED" / "HASCHILDREN" /
"CLOSED" /
"UNKNOWN-CTE" /
atom [SP 1*<any TEXT-CHAR except "]">]
return-option = "SUBSCRIBED" / "CHILDREN" / status-option /
option-extension
search = "SEARCH" [search-return-opts]
SP search-program
search-correlator = SP "(" "TAG" SP tag-string ")"
search-key = "ALL" / "ANSWERED" / "BCC" SP astring /
"BEFORE" SP date / "BODY" SP astring /
"CC" SP astring / "DELETED" / "FLAGGED" /
"FROM" SP astring / "KEYWORD" SP flag-keyword /
"ON" SP date / "SEEN" /
"SINCE" SP date / "SUBJECT" SP astring /
"TEXT" SP astring / "TO" SP astring /
"UNANSWERED" / "UNDELETED" / "UNFLAGGED" /
"UNKEYWORD" SP flag-keyword / "UNSEEN" /
; Above this line were in [IMAP2]
"DRAFT" / "HEADER" SP header-fld-name SP astring /
"LARGER" SP number64 / "NOT" SP search-key /
"OR" SP search-key SP search-key /
"SENTBEFORE" SP date / "SENTON" SP date /
"SENTSINCE" SP date / "SMALLER" SP number64 /
"UID" SP sequence-set / "UNDRAFT" / sequence-set /
"(" search-key *(SP search-key) ")"
; Melnikov & Leiba Expires May 27, 2021 [Page 138]
; Internet-Draft IMAP4rev2 November 2020
search-modifier-name = tagged-ext-label
search-mod-params = tagged-ext-val
; This non-terminal shows recommended syntax
; for future extensions.
search-program = ["CHARSET" SP charset SP]
search-key *(SP search-key)
; CHARSET argument to SEARCH MUST be
; registered with IANA.
search-ret-data-ext = search-modifier-name SP search-return-value
; Note that not every SEARCH return option
; is required to have the corresponding
; ESEARCH return data.
search-return-data = "MIN" SP nz-number /
"MAX" SP nz-number /
"ALL" SP sequence-set /
"COUNT" SP number /
search-ret-data-ext
; All return data items conform to
; search-ret-data-ext syntax.
; Note that "$" marker is not allowed
; after the ALL return data item.
search-return-opts = SP "RETURN" SP "(" [search-return-opt
*(SP search-return-opt)] ")"
search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" /
"SAVE" /
search-ret-opt-ext
; conforms to generic search-ret-opt-ext
; syntax
search-ret-opt-ext = search-modifier-name [SP search-mod-params]
search-return-value = tagged-ext-val
; Data for the returned search option.
; A single "nz-number"/"number"/"number64" value
; can be returned as an atom (i.e., without
; quoting). A sequence-set can be returned
; as an atom as well.
section = "[" [section-spec] "]"
; Melnikov & Leiba Expires May 27, 2021 [Page 139]
; Internet-Draft IMAP4rev2 November 2020
section-binary = "[" [section-part] "]"
section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list /
"TEXT"
; top-level or MESSAGE/RFC822 or MESSAGE/GLOBAL part
section-part = nz-number *("." nz-number)
; body part reference.
; Allows for accessing nested body parts.
section-spec = section-msgtext / (section-part ["." section-text])
section-text = section-msgtext / "MIME"
; text other than actual body part (headers, etc.)
select = "SELECT" SP mailbox
seq-number = nz-number / "*"
; message sequence number (COPY, FETCH, STORE
; commands) or unique identifier (UID COPY,
; UID FETCH, UID STORE commands).
; * represents the largest number in use. In
; the case of message sequence numbers, it is
; the number of messages in a non-empty mailbox.
; In the case of unique identifiers, it is the
; unique identifier of the last message in the
; mailbox or, if the mailbox is empty, the
; mailbox's current UIDNEXT value.
; The server should respond with a tagged BAD
; response to a command that uses a message
; sequence number greater than the number of
; messages in the selected mailbox. This
; includes "*" if the selected mailbox is empty.
seq-range = seq-number ":" seq-number
; two seq-number values and all values between
; these two regardless of order.
; Example: 2:4 and 4:2 are equivalent and indicate
; values 2, 3, and 4.
; Example: a unique identifier sequence range of
; 3291:* includes the UID of the last message in
; the mailbox, even if that value is less than 3291.
sequence-set = (seq-number / seq-range) ["," sequence-set]
; set of seq-number values, regardless of order.
; Servers MAY coalesce overlaps and/or execute the
; sequence in any order.
; Example: a message sequence number set of
; 2,4:7,9,12:* for a mailbox with 15 messages is
; equivalent to 2,4,5,6,7,9,12,13,14,15
; Example: a message sequence number set of *:4,5:7
; for a mailbox with 10 messages is equivalent to
; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and
; overlap coalesced to be 4,5,6,7,8,9,10.
; Melnikov & Leiba Expires May 27, 2021 [Page 140]
; Internet-Draft IMAP4rev2 November 2020
sequence-set =/ seq-last-command
; Allow for "result of the last command" indicator.
seq-last-command = "$"
status = "STATUS" SP mailbox SP
"(" status-att *(SP status-att) ")"
status-att = "MESSAGES" / "UIDNEXT" / "UIDVALIDITY" /
"UNSEEN" / "DELETED" / "SIZE"
status-att-val = ("MESSAGES" SP number) /
("UIDNEXT" SP nz-number) /
("UIDVALIDITY" SP nz-number) /
("UNSEEN" SP number) /
("DELETED" SP number) /
("SIZE" SP number64)
; Extensions to the STATUS responses
; should extend this production.
; Extensions should use the generic
; syntax defined by tagged-ext.
status-att-list = status-att-val *(SP status-att-val)
status-option = "STATUS" SP "(" status-att *(SP status-att) ")"
; This ABNF production complies with
; <option-extension> syntax.
store = "STORE" SP sequence-set SP store-att-flags
store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP
(flag-list / (flag *(SP flag)))
string = quoted / literal
subscribe = "SUBSCRIBE" SP mailbox
tag = 1*<any ASTRING-CHAR except "+">
tag-string = astring
; <tag> represented as <astring>
; Melnikov & Leiba Expires May 27, 2021 [Page 141]
; Internet-Draft IMAP4rev2 November 2020
tagged-ext-label = tagged-label-fchar *tagged-label-char
; Is a valid RFC 3501 "atom".
tagged-label-fchar = ALPHA / "-" / "_" / "."
tagged-label-char = tagged-label-fchar / DIGIT / ":"
tagged-ext-comp = astring /
tagged-ext-comp *(SP tagged-ext-comp) /
"(" tagged-ext-comp ")"
; Extensions that follow this general
; syntax should use nstring instead of
; astring when appropriate in the context
; of the extension.
; Note that a message set or a "number"
; can always be represented as an "atom".
; An URL should be represented as
; a "quoted" string.
tagged-ext-simple = sequence-set / number / number64
tagged-ext-val = tagged-ext-simple /
"(" [tagged-ext-comp] ")"
text = 1*(TEXT-CHAR / UTF8-2 / UTF8-3 / UTF8-4)
; Non ASCII text can only be returned
; after ENABLE IMAP4rev2 command
TEXT-CHAR = <any CHAR except CR and LF>
time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
; Hours minutes seconds
uid = "UID" SP
(copy / move / fetch / search / store / uid-expunge)
; Unique identifiers used instead of message
; sequence numbers
uid-expunge = "EXPUNGE" SP sequence-set
; Unique identifiers used instead of message
; sequence numbers
uid-set = (uniqueid / uid-range) *("," uid-set)
uid-range = (uniqueid ":" uniqueid)
; two uniqueid values and all values
; between these two regards of order.
; Example: 2:4 and 4:2 are equivalent.
; Melnikov & Leiba Expires May 27, 2021 [Page 142]
; Internet-Draft IMAP4rev2 November 2020
uniqueid = nz-number
; Strictly ascending
unsubscribe = "UNSUBSCRIBE" SP mailbox
userid = astring
UTF8-2 = <Defined in Section 4 of RFC 3629>
UTF8-3 = <Defined in Section 4 of RFC 3629>
UTF8-4 = <Defined in Section 4 of RFC 3629>
vendor-token = "vendor." name-component
; Definition copied from RFC 2244.
; MUST be registered with IANA
x-command = "X" atom <experimental command arguments>
zone = ("+" / "-") 4DIGIT
; Signed four-digit value of hhmm representing
; hours and minutes east of Greenwich (that is,
; the amount that the given time differs from
; Universal Time). Subtracting the timezone
; from the given time will give the UT form.
; The Universal Time zone is "+0000".
set ft=abnf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment