I'm not sure if postfix has any add ons that do this, but in my opinion, you can probably bypass the mta completely and just read the mail directories, every email is simply a file inside a directory, with full headers and the message encoded in mime, so you could read the files, parse the headers and count it yourself without involving postifx at all. I'd set up a script to do this every few minutes in a cronjob. That script would check your "max time" by keeping track of when it started, as well as counting max messages and then shut down if/when either is reached.
On Thu, Jul 2, 2015 at 4:02 PM, Marius Gologan <marius.golo...@gmail.com> wrote: > If that server has also a NS role, the "extravaganza" task is questionable. > > -----Original Message----- > From: owner-postfix-us...@postfix.org > [mailto:owner-postfix-us...@postfix.org] On Behalf Of Kirill Peskov > Sent: Thursday, July 2, 2015 6:43 PM > To: postfix-users@postfix.org > Subject: Any elegant way to count all the incoming messages? > > Dear postfix gurus, > > 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). > > > Thanx in advance, > Kirill > >