Re: Sort emails on IMAPS server

Charles Cazabon <[email protected]> Thu, 10 Dec 2020 21:50:07 -0600
Newsgroups gmane.mail.getmail.user
Message-ID <[email protected]>
Please don't top-post to mailing lists.  I've fixed your quoting for this
reply.

Xianwen Chen (้™ˆ่ดคๆ–‡) <[email protected]> wrote:
>
> > > I'm hoping to sort emails on IMAP server before fetching them.
> >
> > Can you explain why?  What exactly you're hoping to accomplish, because the
> > obvious uses - at least the ones that come to mind for me - can all be
> > accomplished with other means with getmail, or are moot.
> 
> I use a two-step workflow.
> 
> In the first step, I fetch all emails from all email accounts into a
> maildir. The maildir is used by IMAP server.
> 
> In the second step, I hope to be able to retrieve emails, for example, 10
> most recent emails at a time, from the maildir's corresponding IMAP server
> to a second maildir. I only read the emails on the second maildir.
> 
> This helps me because I then won't have all the emails at once in my
> mailbox.

You don't need a special feature to do this.  Have getmail remember which
mails it has seen before (so it only fetches any given message once) by
setting read_all = False.  You can then either:

(1) temporarily set your destination to the "old mail" maildir destination.
Run getmail to fetch all extant mail.  Change the configuration back to point
to the "new mail" maildir destination and getmail will deliver all newly seen
(i.e. newly arrived) messages to the "new mail" maildir that you actually
read.

(2) or, don't fiddle configs.  Run getmail once, so it retrieves all extant
mail.  Then use your MUA to move all that mail out of the "new mail" maildir
to your archive or whatever.  Then keep running getmail and only new messages
will be delivered into the destination.

Charles
-- 
-----------------------------------------------------------------------
Charles Cazabon
GPL'ed software available at:               http://pyropus.ca/software/
-----------------------------------------------------------------------