Multidrop retrievers: run filter before sorting ?

Bigaunti - Arcor <[email protected]> Sun, 15 Aug 2021 00:17:20 +0200
Newsgroups gmane.mail.getmail.user
Message-ID <[email protected]>
Good evening,

hopefully this is not a duplicate question - did not find such topic 
back until 2011.

Hope to get hints from you how to change the Getmail (version 5.13) 
script in /usr/bin/getmail such that a multidrop retriever will run a 
filter before it starts sorting the emails.
Such that sorting is done based on the header of the filtered result.
And not on the header in the email as it was retrieved.

Background:

Since long I'm using the multidrop retriever to sort emails based on a 
header "X-Original-To:".

Until my provider was swallowed by some big brother that thought it a 
good idea (I suspect) to stimulate users to buy their high cost services.
So they removed that header component without any usefull replacement.
Now emails are delivered to some ugly box named 123@456789 - that's me now.

Means a low cost user like me gets it all in one, no selection possible 
anymore based on the envelope or header sent by the provider now.

So I composed some shell script to sort things out.
Which adds such header like "X-Original-To:".
So not removing anything, just adding.

And it works fine for me, apart from doing it in 2 steps since then.

First, get them all, let the filter run, then send all to some temp box.
Second, get them again from that temp box, now with that multidrop 
retriever to sort them.

My first attempt to discover where and how this works in Getmail 4.20 
years ago failed.
I'm not familiar with Python.
Going back to school was not a succes - I gave up too early I guess.

Now digging in this version things look different, somewhat more like a 
scripting process.

But no, wrong again, I guess.

I thought to simply interchange the order of the retriever and filter 
section in /usr/bin/getmail.
Getmail however works as before.
All OK, sorting done still based on the retrieved headers.

So I should try to think more object orientated - which is not an easy 
piece of cake for me, having grown up in assembler times.

Therefore this question here:
How complicated will it be in a multidrop retriever to split up the 
retriever part, extend the filterpart such that can be selected whether 
to run it before or after sorting the destinations?
And then let the filter run as desired, in between the retrieval 
process, before sorting, or afterwards when sorting is done.
Can you give me hints how to explore the getmail script for this?

Hope you will give it some time to tell.

Thanks for your attention - and for this fine piece of software anyway.

Sincerely, best regards.

Gert Buitinga
Berlin