MozillaZine

Entire message fetched when opening an IMAP message

From MozillaZine Knowledge Base

This article was written for Thunderbird but also applies to Mozilla Suite / SeaMonkey (though some menu sequences may differ).

Normally, if you open an IMAP message with an attachment and read just the message, Thunderbird only fetches the headers and message body. This is due to the "MIME Parts On Demand" preferences. However, there are some exceptions that can cause it to fetch most or all of the message.

  • If you are configured to use a folder offline, Thunderbird will download the entire message in order to save it in an mbox file, so that it's available when you are working offline. Check whether Tools -> Account Settings -> Offline & Disk Space -> "Select folders for offline use" lists that folder.
  • If you view an image or attachment inline, Thunderbird has to fetch it in order to display it. Depending on how it's stored, this may make Thunderbird fetch the entire message. Check whether View -> Display Attachments Inline is checked.
  • The junk mail controls test the entire message. Check whether Tools -> Account Settings -> Junk Settings -> "Enable adaptive junk mail controls for this account" is checked. [1]
  • When a message filter tests the "body", it actually tests the entire message, not just the message body. All of the other filter criteria just test the headers.

mail.imap.mime_parts_on_demand defaults to true. It specifies that Thunderbird should analyze the messages headers if the message size is larger than mail.imap.mime_parts_on_demand_threshold , and fetch only the pieces of the message that will be displayed online. It defaults to 30000 (30KB). If View -> Display Attachments Inline is not checked, and Thunderbird fetches an attachment when you open a message then you probably need to tweak the threshold. You want to set it as low as possible, but larger than the size of most message bodies. Keep in mind that you may get a message that has both a plain text and a HTML version of the message body (it would have a Content-Type: multipart/alternative header). If you mainly get small plain text messages 8000 (8KB) works well.

mail.imap.mime_parts_on_demand_max_depth controls how complicated the message structure (how many levels of nested attachments for example) has to be before it reverts to fetching the while message. Normally this setting is a not an issue.

mail.imap.fetch_by_chunks controls whether Thunderbird tries to fetch a message body (or any other MIME body part) in chunks. mail.imap.chunk_size controls the size of the chunk. It currently defaults to 10240 bytes. If you set the chunk size too big, it defeats any attempt to fetch just the message body. One problem with enabling fetching by chunks is it breaks the optimizations built into the TCP/IP protocols, and adds extra overhead as each chunk has to be acknowledged. If tweaking the "MIME Parts On Demand" preferences doesn't help, or if it works but you get poor performance, try disabling fetching by chunks.

Contents

Troubleshooting

You can enable IMAP logging and look in the log file to see exactly what Thunderbird fetches from the IMAP server, and when. That might help you understand which setting is causing it to fetch the attachment.

One bug report reports that some users found mail.imap.mime_parts_on_demand was ignored, but setting mail.server.default.mime_parts_on_demand changed the behavior. If none of this helps enter mime_parts and mail.imap in the filter for the Config editor and see if you can find another preference that might have some effect.

Server specific problems

Gmail's IMAP implementation [2] originally did not support the IMAP Body Structure message attribute. If it's missing, Thunderbird downloads the entire message. The latest IMAP spec. (RFC 3501) doesn't require that an IMAP server support that feature, but most IMAP servers do. Gmail fixed that problem 25 Jan 2008. You can verify that your email provider supports that feature by enabling IMAP logging and searching for (BODYSTRUCTURE).

Another possibility would be if you were using a Courier IMAP server that defaults to 4 TCP-IP connections per IP address, and you didn't lower the maximum number of server connections to cache accordingly in Thunderbird. See this article for more information.

Message body not downloaded

If you get "This body part will be downloaded on demand." instead of the message body when you open a message Thunderbird for some reason decided it was an attachment, and deferred loading it. Try rebuilding the index (right click on the remote folder, select properties, and press the Rebuild Index button) [3]

You should only get this message if you have a message with multiple parts. Look at the message source by selecting the message and then pressing Control-U. Find the Content-Type: header near the subject. Look at the first word after Content-Type:. It should start with "multipart" such as Content-Type: multipart/mixed; , Content-Type: multipart/related; or Content-Type: multipart/alternative; and you should find something like This is a multi-part message in MIME format. right after the headers.

Otherwise there is only one MIME section (one body part) so there is nothing to delay downloading. If you see that text and the message has only one body part then you've probably either discovered a bug or the message is corrupt.

See also

External links