On 2021-06-22 at 05:11:13 UTC-0400 (Tue, 22 Jun 2021 10:11:13 +0100)
D.C. Ebdon <[email protected]>
is rumored to have said:

Hi there

I'm hoping to 'fix' an issue with some software I have to use for work that
can't/won't be fixed in the software itself.

In general, a MTA is a very poor place to try to fix problems created by mail generators that are badly designed.

Basically the software sends
(in the space of a few seconds) two emails with an attachment apiece, where
really there should just be one email with two attachments.
The emails are already routed through my locally hosted postfix relay on to
Gmail and this works really well.
I was hoping to use milter to detect the two emails heading to the same recipient within a few seconds of each other, fold them into one email and
send them on to gmail.

This is a bit like what some mailing list managers (e.g. GNU Mailman) do when merging messages into 'digests' containing multiple messages. It is worth noting that mailing list managers are NOT milters, but rather accept delivery of mail and then re-inject modified or merged mail later. The Milter interface operates 'live' on individual messages as they are being offered and accepted for delivery, and it is a very poor fit architecturally for correlating multiple messages and performing intentional delays.

If someone was able to help with setting this up I'd be really grateful.

I can't offer significant assistance but I do have a couple of suggestions:

1. Don't make any milter do the complex multi-message part of this. Figure out how to detect possible members of message pairs and divert those to a local mailbox, then use Something Else to bundle up the messages and re-inject them. Milter has no concept of handling multiple messages as related objects.

2. If you are committed to using a milter for this, you need to recognize that no existing milter will do it without some degree of programming effort to modify/enhance the milter to add backend queueing and re-injection which you will need to design. The most widely-used milter I know of which enables such enhancement without excessive pain is MIMEDefang, which is configured by way of creating Perl subroutines which are called at the different phases of the Milter API. MIMEDefang is the core platform for some very sophisticated mail handling systems. Its original author, Dianne Skoll, has also forked a radical rewrite of it called Mailmunge which I expect could also be a platform for your needs.

In the end, I think your best option is just to live with it or find a way to fix the problem *before* it turns into 2 messages that should be one.

--
Bill Cole
[email protected] or [email protected]
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Not Currently Available For Hire

Reply via email to