tags:

views:

35

answers:

2

Just want a basic understand of what parts a email message may have.

I know there is a messageId, date, subject, from, cc, bcc, body, etc.

Specifically I want to know how attachments and images may be embedded in the email.

At this point I think there are 2, please correct me if I am wrong.

  1. attachments
  2. embedded attachments/images

is that correct?

+3  A: 

The official answer for this question is contained in RFC5322 and some related RFC's. The Wikipedia entry for email does a pretty good job of referencing the RFC numbers. To get started with MIME see RFC2045.

DigitalRoss
+1  A: 

Attachments are encoded as multipart similar to multipart file uploads. Basically the message has a header saying there is an attachment and sets a boundary ( random string of characters to announce the start of the attachment) The boundary says when the data of the attachment starts. I think the filename is set on the boundary as well (if i remember correctly). I am doing a bit of hand waving, but this is the basic idea.

so you get somthing like

To: ...
From: ...
Content-Type: Multpart...
Content-Boundry: ewafoiuasfjasdfoashiafhj

 message here

--------- Content-boundry: ewafoiuasfjasdfoashiafhj
 attachement here
Byron Whitlock