Log In
New Account
Home My Page Project Cloud Code Snippets Project Openings modest
Summary Lists SCM Wiki

Attachment Detection

Attachment Detection

On this page, we discuss the way to detect attachments coming from various e-mail clients.

We refer as "standard behavior" as this:

  • Plain text messages: top mime part is a text/plain
  • HTML messages: top mime part is a multipart/alternate with two children (text/plain and text/html), or it's directly a text/html.
  • HTML messages with embedded images: top mime part is a multipart/related. One child is a multipart/alternate (see previous point). Other children are the embeded images.
  • Message with attachments: top mime part is a multipart/mixed, with a child being the structure of non attachments messages (as we saw in previous points), and other children the attachments
  • Signed message: top mime part is a multipart/signed.

Mime structure created in different clients

Let's keep 'm in alphabetical order :)


Standard behavior.

Signed messages are multipart/signed.


Standard behavior. Uses multipart/mixed for emails with attachments, multipart/alternative for hmtl/txt mails, multipart/related for html with images.


Standard behavior. Currently, windows live hotmail only supports plain text.


Standard behavior. Uses multipart/mixed for emails with attachments, multipart/alternative for html/txt mails, multipart/related for html with images.


Standard behavior.


Standard behavior (but it does not support html messages)

Outlook / Outlook Express

Use the X-Ms-Has-Attach header (and if a mail has any of X-MS-* headers, _not_ having X-Ms-Has-Attach means there is _no_ attachment.

Outlook currently provides standard behavior also.

Special outlook format: send a file as the top mime part. The top mime part has the content type of the file.


PHP mail mime from pear has standard behavior.

SMIL (MMS) message

They have "Content-Type: Multipart/Related;" as the top-level. MMS message do not *always* contain images/video's, but I guess that "X-Mms-Message-ID:" and this Multipart/Related means it has an attachment.

Note: in fact we should interpret any smil message as having attachments, because we'll show the body of the smil message as an attachment in modest.


Standard behavior (only supports plain text messages).


Standard behavior.


Uses multipart/mixed for mails with attachments

Mime parsing in different clients

Standard behavior would be simply recognising top multipart/mixed to determine if it's an attachment.


Standard behavior


It considers any multipart/related and multipart/mixed as message with attachments (then messages with embedded images only are considered as having attachments).


It considers (in imap):

  • Any message with a size greater than 102400
  • Any message having a X-MS-Priority field, unless it does not provide a X-MS-Has-Attachments field.
  • Proposal: consider as having attachments nearly any message with multipart/mixed. We would exclude this way the outlook file as top mime part method.


Any multipart is considered as having attachments.

(last edited April 28, 2009) - Read Only [info] [diff])
FindPage by browsing or searching
5 best incoming links: FrontPage (7), RecentChanges (5)
5 best outgoing links:
5 most popular nearby: FrontPage (4485), RecentChanges (689)

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment