[IMAP] Option to only sync envelope
Open, Needs TriagePublic

Description

Currently we either sync PLD:ENVELOPE, PLD:HEAD and PLD:RFC822 (when "Download messages for offline use" is enabled) or PLD:ENVELOPE + PLD:HEAD (the so-called "online IMAP"). Considering that majority of messages today contain many large DKIM, SPF, Delivered-to and similar headers, the size of the PLD:HEAD is substantial.

The idea is to only sync selected headers so that we can populate PLD:ENVELOPE and not sync PLD:HEAD at all - when user opens the message, we download the entire message anyway, and storing 2x5kB of headers + 1kB of message text seems like a huge waste of disk space.

To make this work, only a small change in KIMAP is required so that KIMAP::FetchJob::Headers scope fetches all headers needed by the MIME serializer and a small change in the IMAP resource to only put "Envelope" into Collection's cached parts (instead of Envelope and Head, which it does now) and to request the Headers scope instead of FullHeaders.

I've been testing the changes locally for a bit with one account and the sync is a bit faster now but more importantly the folder takes much less space: ENVELOPE is ~700 bytes on average compared to 3.5kB average for PLD:HEAD (sampled on a single folder with 80k+ messages)

However, ENVELOPE does not contain any X-* headers, so local mailing lists filters will not work - hence I think we should change the "Download messages for offline use" option in the IMAP resource into a combobox with following options with some explanation

  • Download full messages for offline use [default, PLD:ENVELOPE, PLD:RFC822]
  • Download full message headers [PLD:ENVELOPE,PLD:HEAD]
  • Download only minimal headers [PLD:ENVELOPE]

With the last option showing a warning that some local mail filters may not work properly.