2
votes

I'm trying to learn about the values of the IMAP BODYSTRUCTURE , but am facing some confusion and would appreciate if you could offer your guidance.

Sending a simple 1 line email via gmail returns this BODYSTRUCTURE

example 1
BODYSTRUCTURE (("text" "plain" ("charset" "utf-8") NIL NIL "7bit" 10 1 NIL NIL NIL NIL)("text" "html" ("charset" "utf-8") NIL NIL "7bit" 35 1 NIL NIL NIL NIL) "alternative" ("boundary" "001a113a6490bbcac5051c86cddc") NIL)

Sending a slightly different email via gmail returns this

example 2
BODYSTRUCTURE ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 12535 548 NIL NIL NIL NIL)

Copy/pasted from rfc3501 page 74, a 48 line email contain this BODYSTRUCTURE

example 3
("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 2279 48)

Using example 2, and reading from page 75 rfc3501, this is what i understand/misunderstand:

value #1 "text" = body type

value #2 "plain" = body subtype

value #3 ("charset" "us-ascii") = body parameter parenthesized list. this is the encoding like ASCII or unicode right?

value #4 NIL = body id

value #5 NIL = body description

value #6 "7 bit" = body encoding

value #7 12535 = body size in octets - what is an octet? this is not defined in rfc3501

value #8 548 = body md5 value. this is the standard md5 hash value no?

value #9 - 12 NIL = body disposition, language & location?

Here are my questions:

1, Example 1 and Example 2 are almost the same email, but have completely different bodystructures. Why?

2, What values can and cannot be NIL? For example, in rfc3501 for envelope structure, its very specific about what can and cannot be nil, but information for bodystructure is very vague. There are also an extra NIL not defined in rfc3501 on example 1 and 2 and every IMAP server I try.

3, Can someone explain to me, item by item, what example #1 is so I know how to parse it? It appears to contain 2 different BODYSTRUCTURES, but the parts about "boundary" and "alternative" I do not understand.

I know its a large question but I would really appreciate the help. Thanks.

1

1 Answers

0
votes

Examples 1 and 2 refer to completely different messages; example 1 is one line of text sent as two alternative formats (HTML and plain text, the reader get to pick preferred alternative), while example two is 548 lines of plain text.

Look at the source of example one, you'll see what happens.

I disagree with your assertion that the documentation for bodystructure is very vague, so I don't think I can explain that effectively to you. Instead, I suggest that you go through that part of 3501 with with a few example messages and their bodystructure responses. It'll take you a few hours. Your two example messages should do, you might want to add a third example where there's an attachment with a filename.

An octet is a byte (or rather, "byte" now refers unambiguously to 8 bits, which hasn't always been the case).