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 maxageWhy 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:
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.