Message = [Crappy-header CRLF] Message-headers CRLF Content-headers CRLF

Crappy-header = "Content-Type: Message/CPIM" CRLF

Message-headers = 1*( Message-header CRLF )
Message-header = From-header / To-header / DateTime-header / cc-header / Subject-header / NS-header / Require-header / Header

Content-headers = 1*( Header CRLF )

Header = Header-name ":" Header-parameters SP Header-value

Header-name = [ Name-prefix "." ] Name
Name-prefix = Name

Header-parameters = *( ";" Parameter )

Parameter = Lang-param / Ext-param
Lang-param = "lang=" Language-tag
Ext-param = Param-name "=" Param-value
Param-name = Name
Param-value = Token / Number / String

Header-value = *HEADERCHAR

From-header = %d70.114.111.109 ": " From-header-value
From-header-value = [ Formal-name ] "<" URI ">"

To-header = %d84.111 ": " To-header-value
To-header-value = [ Formal-name ] "<" URI ">"

DateTime-header = %d68.97.116.101.84.105.109.101 ": " DateTime-header-value
DateTime-header-value = date-time

cc-header = %d99.99 ": " cc-header-value
cc-header-value = [ Formal-name ] "<" URI ">"

Subject-header = %d83.117.98.106.101.99.116 ":" Subject-header-value
Subject-header-value = [ ";" Lang-param ] SP Header-value

NS-header = %d78.83 ": " NS-header-value
NS-header-value = [ Name-prefix SP ] "<" URI ">"

Require-header = %d82.101.113.117.105.114.101 ": " Require-header-value
Require-header-value = Header-name *( "," Header-name )

Name = 1*NAMECHAR
Token = 1*TOKENCHAR
Number = 1*DIGIT
String = DQUOTE *( Str-char / Escape ) DQUOTE
Str-char = %x20-21 / %x23-5B / %x5D-7E / UCS-high
Escape = "\" ( "u" 4(HEXDIG) / "b" / "t" / "n" / "r" / DQUOTE / "'" / "\" )

Formal-name = 1*( Token SP ) / String

HEADERCHAR = UCS-no-CTL / Escape

NAMECHAR = %x21 / %x23-27 / %x2a-2b / %x2d / %x5e-60
	/ %x7c / %x7e / ALPHA / DIGIT

TOKENCHAR = NAMECHAR / "." / UCS-high

UCS-no-CTL = UTF8-no-CTL
UCS-high = UTF8-multi
UTF8-no-CTL = %x20-7e / UTF8-multi
UTF8-multi = %xC0-DF %x80-BF
	/ %xE0-EF %x80-BF %x80-BF
	/ %xF0-F7 %x80-BF %x80-BF %x80-BF
	/ %xF8-FB %x80-BF %x80-BF %x80-BF %x80-BF
	/ %xFC-FD %x80-BF %x80-BF %x80-BF %x80-BF %x80-BF

URI = absoluteURI

absoluteURI = scheme ":" ( hier-part / opaque-part )
relativeURI = ( net-path / abs-path / rel-path ) [ "?" query ]

hier-part = ( net-path / abs-path ) [ "?" query ]
opaque-part = uric-no-slash *uric

uric-no-slash = unreserved / escaped / ";" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / ","

net-path = "//" authority [ abs-path ]
abs-path = "/" path-segments
rel-path = rel-segment [ abs-path ]

rel-segment = 1*( unreserved / escaped / ";" / "@" / "&" / "=" / "+" / "$" / "," )

scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )

authority = server / reg-name

reg-name = 1*( unreserved / escaped / "$" / "," / ";" / ":" / "@" / "&" / "=" / "+" )

server = [ [ userinfo "@" ] hostport ]
userinfo = *( unreserved / escaped / ";" / ":" / "&" / "=" / "+" / "$" / "," )

hostport = host [ ":" port ]
host = hostname / IPv4address / IPv6address
ipv6reference = "[" IPv6address "]"
hostname = *( domainlabel "." ) toplabel [ "." ]
domainlabel = alphanum / alphanum *( alphanum / "-" ) alphanum
toplabel = ALPHA / ALPHA *( alphanum / "-" ) alphanum
IPv6address = hexpart [ ":" IPv4address ]
IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
port = *DIGIT

IPv6prefix  = hexpart "/" 1*2DIGIT
hexpart = hexseq / hexseq "::" [ hexseq ] / "::" [ hexseq ]
hexseq = hex4 *( ":" hex4)
hex4 = 1*4HEXDIG

path = [ abs-path / opaque-part ]
path-segments = segment *( "/" segment )
segment = *pchar *( ";" param )
param = *pchar
pchar = unreserved / escaped / ":" / "@" / "&" / "=" / "+" / "$" / ","

query = *uric

fragment = *uric

uric = reserved / unreserved / escaped
reserved = ";" / "/" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / "," / "[" / "]"
unreserved = alphanum / mark
mark = "-" / "_" / "." / "!" / "~" / "*" / "'" / "(" / ")"

escaped = "%" HEXDIG HEXDIG

alphanum = ALPHA / DIGIT

Language-Tag = Primary-subtag *( "-" Subtag )
Primary-subtag = 1*8ALPHA
Subtag = 1*8(ALPHA / DIGIT)

date-fullyear = 4DIGIT
date-month = 2DIGIT
date-mday = 2DIGIT

time-hour = 2DIGIT
time-minute = 2DIGIT
time-second = 2DIGIT

time-secfrac = "." 1*DIGIT
time-sign = "+" / "-"
time-numoffset = time-sign time-hour ":" time-minute
time-offset = "Z" / time-numoffset

partial-time = time-hour ":" time-minute ":" time-second [ time-secfrac ]

full-date = date-fullyear "-" date-month "-" date-mday
full-time = partial-time time-offset

date-time = full-date "T" full-time
