On Wed, Dec 01, 2021 at 02:51:39PM -0500, Wietse Venema <[email protected]> 
wrote:

> Aleksandar Ivanisevic:
> > Hi,
> > 
> > is there a hook that can be run after a SMTP delivery attempt, right before 
> > or after this line is logged, passing some or all the data in this line?
> > 
> > Nov 28 03:43:30 mail1 postfix/smtp[1441795]: CB8C41C1C976: 
> > to=<[email protected]>, 
> > relay=hotmail-com.olc.protection.outlook.com[104.47.13.33]:25, delay=2.7, 
> > delays=0.22/0/0.3/2.2, dsn=2.6.
> > 0, status=sent (250 2.6.0 
> > <1079627886.228389.1638071007339.JavaMail.be@NTF01> 
> > [InternalId=34123515169457, 
> > Hostname=DM5PR0401MB3608.namprd04.prod.outlook.com] 16724 bytes in 0.315, 
> > 51.835 KB/sec Qu
> > eued mail for delivery -> 250 2.1.5)
> > 
> > also for unsuccessful deliveries, e.g.
> > 
> > Dec  1 19:29:26 mail1 postfix/smtp[1573818]: EFD1A1C1C973: 
> > to=<[email protected]>, relay=mx02.mail.icloud.com[17.57.152.14]:25, 
> > delay=3.5, delays=0.21/0/2.2/1.1, dsn=5.1.1, status=bounced (host 
> > mx02.mail.icloud.com[17.57.152.14] said: 550 5.1.1 <[email protected]>: user 
> > does not exist (in reply to RCPT TO command))
> > 
> 
> Yes, and the hook is called syslog. In syslog.conf (or whatever it
> is called on your system) configure a "deliver to pipe" option to
> a program that looks at the records of interest at the time they
> are logged.
> 
> There is no non-Postfix code running in the process context
> of a Postfix process. You're welcome to use a less secure mail
> system if you need a tighter level of integration than Postfix
> provides.
> 
>       Wietse

A nice method is to use swatch/swatchdog to monitor the
files that syslog produces, and act when it detects
patterns that you are interested in.

cheers,
raf

Reply via email to