Limiting the number (by date) of IMAP headers fetched in mutt

imapmutt

I'm using mutt to open an IMAP folder (gmail) that has a lot of messages (hundreds of thousands), so I'd like to tell mutt to fetch only messages less than 1 week old (for example), since fetching headers for all of them takes several minutes (or more).

After googling the problem for hours, I haven't found any answers that would help (one suggestion to cache headers helped somewhat by reducing the time from dozens of minutes to single digit minutes, but it's still slow).

It sounds to me like this is in principle an easy problem to solve, but I don't know how; any help would be greatly appreciated.

Best Answer

Mutt or Neomutt doesn't support this behaviour now. Dealing with large mailboxes isn't always easy.

There are tools to sync emails to your local mailboxes that support what you want.

imapsync supports the functionality you need with --maxage option.

offilneimap does similar with configuration option maxage

Why to bother with options above when you already need to configure imap-to-mailbox synchronization tool? So I would stick with syncing them all.

There are benefits of having messges localy:

  • working with large mailboxes is fast (OK, I still need header cache to load ~46000 msgs in 3-4 seconds)
  • search and view messages offline
  • easily backup all your e-mails
  • doesn't consume too much space. In my case 46692 msgs = 3414 MB.

GMail support limiting IMAP access to last ### messages (based on count, not age). Maybe some other e-mail providers has solution you want. But then you're dependent on a specific provider.

Related Question