I need to implement solution on my postfix/dovecot server which will execute bash script every time message arrives. For this purpose I did following things in master.cf configuration
myhook unix - n n - - pipe
flags=F user=customUser argv=/path/to/script.sh ${sender} ${recipient}
smtp inet n - - - - smtpd
-o content_filter=myhook:dummy
Works fine as long as you don't want to emails being delivered to mailboxes via dovecot. The problem is, that somehow I need to 'throw' back everything to dovecot. Or maybe there is a better approach, which is not known by me.
I appreciate every idea or tip in this case.
Best Answer
Your script must act like Simple content filter example from Postfix official documentation. After postfix send the email via
pipe
, you must resubmit it viasendmail
command. Snippet from that page