Hi, to answer your question I messed around even though i don't think this is 
going to do it for you but it's a start.

master.cf

filter    unix  -       n       n       -       0      pipe
  -o syslog_name=postfix/trigg
  flags=Fq      user=filter
  null_sender= argv=/usr/local/bin/angelo  ${sender}  ${recipient}

header_checks
/^Subject: .*stuff.*/ FILTER filter:
/^subject:/ WARN

The major problem is i have not figured out how to deliver the original email 
that triggered the filter
in the first place.

here is logs of it working, and running my "angelo" script based on email 
subject

Dec  5 13:34:42 mta5 postfix/smtpd[1432]: connect from 
angelo.uits.uconn.edu[137.99.80.129]
Dec  5 13:34:43 mta5 postfix/smtpd[1432]: 092653000371: 
client=angelo.uits.uconn.edu[137.99.80.129]
Dec  5 13:34:43 mta5 postfix/cleanup[1438]: 092653000371: filter: header 
Subject: this is stuff in here from angelo.uits.uconn.edu[137.99.80.129]; 
from=<[email protected]<mailto:[email protected]>> 
to=<[email protected]<mailto:[email protected]>> proto=ESMTP 
helo=<[137.99.80.129]>: filter:
Dec  5 13:34:43 mta5 postfix/cleanup[1438]: 092653000371: 
message-id=<[email protected]<mailto:[email protected]>>
Dec  5 13:34:43 mta5 opendkim[1494]: 092653000371: DKIM-Signature field added 
(s=dkim1, d=mta5.uits.uconn.edu)
Dec  5 13:34:43 mta5 postfix/qmgr[1246]: 092653000371: 
from=<[email protected]<mailto:[email protected]>>, size=721, 
nrcpt=1 (queue active)
Dec  5 13:34:43 mta5 postfix/smtpd[1432]: disconnect from 
angelo.uits.uconn.edu[137.99.80.129]
Dec  5 13:34:43 mta5 postfix/trigg/pipe[1441]: 092653000371: 
to=<[email protected]<mailto:[email protected]>>,
 orig_to=<[email protected]<mailto:[email protected]>>, 
relay=filter, delay=0.17, delays=0.12/0.02/0/0.03, dsn=2.0.0, status=sent 
(delivered via filter service)
Dec  5 13:34:43 mta5 postfix/qmgr[1246]: 092653000371: removed
Dec  5 13:34:43 mta5 postfix/pickup[1245]: 2D3293000395: uid=1038 from=<filter>
Dec  5 13:34:43 mta5 postfix/cleanup[1438]: 2D3293000395: warning: header 
Subject: Your email to 
[email protected]<mailto:[email protected]> was delivered 
from local; from=<[email protected]<mailto:[email protected]>>
Dec  5 13:34:43 mta5 postfix/cleanup[1438]: 2D3293000395: 
message-id=<[email protected]<mailto:[email protected]>>
Dec  5 13:34:43 mta5 opendkim[1494]: 2D3293000395: DKIM-Signature field added 
(s=dkim1, d=mta5.uits.uconn.edu)
Dec  5 13:34:43 mta5 postfix/qmgr[1246]: 2D3293000395: 
from=<[email protected]<mailto:[email protected]>>, size=802, 
nrcpt=1 (queue active)
Dec  5 13:34:44 mta5 postfix/smtp[1446]: 2D3293000395: 
to=<[email protected]<mailto:[email protected]>>,
 
relay=uconn-mail-onmicrosoft-com.mail.protection.outlook.com[104.47.55.110]:25, 
delay=1.7, delays=0.06/0.02/0.28/1.3, dsn=2.6.0, status=sent (250 2.6.0 
<[email protected]<mailto:[email protected]>>
 [InternalId=20963735375625, Hostname=MWHPR05MB2973.namprd05.prod.outlook.com] 
10746 bytes in 0.174, 60.000 KB/sec Queued mail for delivery)
Dec  5 13:34:44 mta5 postfix/qmgr[1246]: 2D3293000395: removed

But as you can see i don't understand Postfix well enough to make a proper 
script, or reroute to another Postfix instance as suggested in other threads 
from
my searching here http://postfix.1071664.n5.nabble.com/

Also i thought i could swap my script for the one in documentation here
http://www.postfix.org/FILTER_README.html
but i got a permission error.

Dec  5 13:27:05 mta5 postfix/qmgr[29586]: 42D50300039A: 
from=<[email protected]<mailto:[email protected]>>, 
size=1518, nrcpt=1 (queue active)
Dec  5 13:27:15 mta5 postfix/trigg/pipe[1078]: 42D50300039A: 
to=<[email protected]<mailto:[email protected]>>,
 orig_to=<[email protected]<mailto:[email protected]>>, 
relay=filter, delay=9057, delays=9047/0.02/
0/10, dsn=4.3.0, status=deferred (temporary failure. Command output: 
/usr/local/bin/trigger: line 21: in.1079: Permission denied Cannot save mail to 
file )

Sorry i can't be more helpful, good luck.

-ANGELO FAZZINA

[email protected]<mailto:[email protected]>
University of Connecticut,  ITS, SSG, Server Systems
860-486-9075


Hi Angelo,
thanks for your quick reply.
I had a look at your solution, but I'd need a filter on the subject, not on 
sender or recipient. Can your solution be modified to include subject filtering 
as well?
Grazie :-)

On Wed, 4 Dec 2019 at 21:20, Fazzina, Angelo 
<[email protected]<mailto:[email protected]>> wrote:
Hi, AFA I know there is the “argv” parameter in 
master.cf<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaster.cf&data=02%7C01%7Cangelo.fazzina%40uconn.edu%7Cca1d1c47e2234bccb28308d778f9e346%7C17f1a87e2a254eaab9df9d439034b080%7C0%7C0%7C637110886960899887&sdata=2oEICgu%2FmRmdCWeM2HgAKto7RFNKUI2mmEobpX6nsGU%3D&reserved=0>
 that can run scripts you create, there may be others.
This is my test config:
autoreply unix  -       n       n       -       -       pipe
        flags=DF        user=nobody
        argv=/usr/local/bin/angelo $sender $recipient $original_recipient $user 
 $mailbox
And here is the script:
[root@mta5 ]# more /usr/local/bin/angelo
#!/usr/bin/bash
/usr/sbin/sendmail -oi -t <<EOF
From: UConn Help Center <[email protected]<mailto:[email protected]>>
To: $1
Subject: Your email to $3 was delivered
Content-Type: text/plain; charset=utf-8
This is a test email.
This is a notice to inform you that in the future when you send emails
to $3 they will fail to send.
Please send all future emails to users  
@uconn.edu<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fuconn.edu&data=02%7C01%7Cangelo.fazzina%40uconn.edu%7Cca1d1c47e2234bccb28308d778f9e346%7C17f1a87e2a254eaab9df9d439034b080%7C0%7C0%7C637110886960909879&sdata=L52YmElqXh6KwYJRAmqauJ%2BH62PyYouJQk%2Bp1HaAtwc%3D&reserved=0>
 address.
Thank you.
this is 2 = $2
this is 1 = $1
this is 3 = $3
this is user = $4
this is mailbox = $5

Reply via email to