On Thu, Jul 02, 2015 at 03:42:46PM +0000, Kirill Peskov wrote:

> Could you, please, suggest the method to setup a message counter on
> SMTP, so every incoming message regardless exact content of To: Cc: or
> Bcc: fields (e.g. one SMTP transaction) would increase the counter by
> one or call corresponding bash script able to do that? I've got
> development task to create a sort of ephemeral MX which should run only
> limited amount of time and/or process only limited amount of messages.
> After it reaches MAX_MESSAGES or MAX_UPTIME (whatever comes first), the
> server should check if all the queues are empty, stop postfix and reboot
> or shutdown itself (don't ask me why do I need such extravaganza, ;)
> that's simply must be a part of our continuous integration workflow).

Route all the messages to a pipe(8) transport with a process limit
of 1.  The program invoked by that transport can implement the
requisite logic.   You can even send an additional final message
that lists the message-ids of all the previous ones, and the program
can initiate meltdown once all the messages in question have been
processed (the final message might arrive before some of the rest,
but that's OK, just meltdown when the last missing message arrives,
or immediately if all have already arrived).

As for a global timeout, implement that outside Postfix (postfix stop).

-- 
        Viktor.

Reply via email to