I'm struggling to achieve the kind of filtering with sieve that I was able to do with procmail.
TL;DR
I'd like a way to loop through a set of (address, destination) pairs in sieve so that I can maintain the (address, destination) pairs in one place and not have to explicitly write scores of nearly identical
[...]
if address :matches ["From", "Sender", "To", "Cc"] "address53" { fileinto "destination53" }
if address :matches ["From", "Sender", "To", "Cc"] "address54" { fileinto "destination54" }
[...]
Longer:
I've been using a table-based dispatch approach with procmail for years and it was working reasonably well.
The approach uses list of pairs of address and destination boxes and doing a lookup based on the message to be delivered. With procmail, I collected the list of addresses and passed them to external scripts to do the lookup.
If I just had a dozen boxes that I deal with, that would be straightforward to implement and maintain in sieve. As the list is an order of magnitude greater than that, maintaining the list of pairs in an external file and programmatically looping through it is a lot easier.
I've looked at vnd.dovecot.execute and it certainly can return a destination box name given the input information.
Unfortunately, the construct of (for example)
address :matches "To" "*"'
only returns the first address, not the list of addresses.
I can't see a good way to get all the addressees from sieve to pass to the external program. If I have to pass the message (or at least the interesting headers) to the external program and then parse the address list myself, then I'm nearly all the way to just using a full-on external program to parse the whole message.
While I'm not adverse to writing the whole thing in Python (or the like) and just using sieve as a thin shell, I'd like to make sure I'm not missing something in sieve.
One way to achieve this would be to be able to loop through the pairs and using variable substitution for each iteration. I haven't seen anything in Dovecot Pigeonhole sieve that allows this.
If you have any ideas on how to harness sieve for this, I'd appreciate it!
Jeff