2

I want to run a program when postfix has successfully sent out a mail (local or remote). I would like to pass the headers to program and if possible also the destination ip or address (exclude spam filter delivery).

I just have an idea: Delivery Status Notification processing via uniqe transport program, but I'd prefer the above.

My goal is to be recorded lifetime (events) of email: it came, it went out (from, to, subject, datetime, message id, message status: bounce, sent). I would only need the state of the outgoing mail, because incoming and bounce program is working.

It is possible to trigger a program (similar to a transport pipe/spawn) or DSN "cheat" stay?

Thanks in advance for any reply!

0

2 Answers 2

1
+100

This is only for logging message headers.

By default postix already logs most of this information, though not in one line. It doesn't, however, log the subject or message-id. We can add that in by using header_checks 5.
Note: for all mail and not just outgoing, use header_checks instead of smtp_header_checks.


#main.cf
smtp_header_checks = regexp:$config_directory/header-logging.cf


#header-logging.cf
/^subject:/      INFO
/^Subject:/      INFO
/^Message-Id:/   INFO

These messages will be logged to syslog in the facility specified by syslog_facility (default: mail).

Apr  9 15:37:25 mta-msa postfix/smtps/smtpd[14688]: DA75A231C600: client=192-0-2-5.example.com[192.0.2.5], sasl_method=LOGIN, sasl_username=foo
Apr  9 15:37:25 mta-msa postfix/cleanup[14686]: DA75A231C600: message-id=<[email protected]>
Apr  9 15:37:25 mta-msa postfix/qmgr[14653]: DA75A231C600: from=<[email protected]>, size=6495, nrcpt=1 (queue active)
Apr  9 15:37:26 mta-msa postfix/smtp[14675]: DA75A231C600: info: header Subject: RE: please email as you leave
Apr  9 15:37:26 mta-msa postfix/smtp[14675]: DA75A231C600: info: header Message-ID: <[email protected]>
Apr  9 15:37:26 mta-msa postfix/smtp[14675]: DA75A231C600: to=<[email protected]>, relay=mx.example.org[198.51.100.0]:25, delay=0.65, relays=0.01/0/0.33/0.31, dsn=2.0.0, status=sent (250 2.0.0 1tnx2ya0mh-1 Message accepted for delivery)
Apr  9 15:37:26 mta-msa postfix/qmgr[14653]: DA75A231C600: removed
0

You could do this with something that is inserted into the postfix processing pipeline like amavisd-new does.

In short, postfix is configured to have a new service in postfix's master.conf. that service will be a small program that saves a copy of the messages and then re-inserts the messages into postfix.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .