Postfix – How to Deliver Email to Inbox Using Procmail

postfixprocmail

I have setup a Postfix mail server, and my goal was to pipe incoming emails to a script. I did this via Procmail. The script is getting run without any issues.

my issue is: I want to deliver a copy of the incoming email to the users inbox as well.
following is my .procmailrc file. Also I'm using Maildir format.

LOGFILE=$HOME/procmail.log
VERBOSE=YES
SHELL=/bin/sh
MAILDIR=$HOME/Maildir
:0
|/home/user1/script.sh

:0c
[email protected]

with the above .procmailrc file, script is getting run, but no email is getting delivered to users inbox.

Best Answer

You need a c flag on the first recipe (and no c flag on the second, unless you want a third copy of the message after this delivery).

In very brief, the first successful delivering recipe terminates Procmail's processing of this message. If you want it to continue after that point, add a c ("clone") flag (but in more complex scenarios perhaps also some sort of error checking and fallback processing, via the e and/or E flags).

Related Topic