[CentOS] CentOS 6, Postfix, and Procmail -- how do I get it to work?

Mon Aug 18 20:33:19 UTC 2014
Mike Burger <mburger at bubbanfriends.org>

On 2014-08-18 3:42 pm, Robert Heller wrote:
> At Mon, 18 Aug 2014 13:39:49 -0400 Mike Burger
> <mburger at bubbanfriends.org> wrote:
> 
>> 
>> On 2014-08-18 1:26 pm, Robert Heller wrote:
>> > What is the trick to get Postfix's local command to pipe mail through
>> > procmail?
>> >
>> > I have:
>> >
>> > -bash-4.1$ grep allow_mail_to_commands /etc/postfix/main.cf
>> > allow_mail_to_commands = alias, forward
>> >
>> > and
>> >
>> > -bash-4.1$ cat .forward
>> > |/usr/bin/procmail
>> >
>> > and a .procmailrc file:
>> >
>> > -bash-4.1$ cat .procmailrc
>> > PATH=/usr/bsd:/bin:/usr/bin:/exp/rcf/share/bin
>> > MAILDIR=/var/lib/amanda/Mail      #you'd better make sure it exists
>> > DEFAULT=$ORGMAIL   #completely optional
>> > LOGFILE=$MAILDIR/from   #recommended
>> >
>> > :0
>> > * ^From.*no-reply at sns.amazonaws.com
>> > |$HOME/retrieveArchive.tcl
>> >
>> > :0
>> > ! heller at deepsoft.com
>> >
>> > Basically I want all mail to the Amanda Backup account, except messages
>> > from
>> > Amazon SNS, to be forwarded to me (the system admin).  The
>> > retrieveArchive.tcl
>> > is a script to process Amazon SNS messages.
>> 
>> It's this simple:
>> 
>> Instead of putting a call to procmail in your .forward, first, set up
>> /etc/postfix/main.cf with the following line:
>> 
>> mailbox_command = /usr/bin/procmail
>> 
>> and reload postfix. Now, postfix will default to using procmail as its
>> local delivery agent.
>> 
>> Now, set up /etc/procmailrc like so:
>> 
>> USER=`whoami`
>> 
>> :0 fw
>> | spamc
>> 
>> :0 e
>> {
>>          EXITCODE=$?
>> }
> 
> I don't have spamassin set up -- it is not needed, since this is not a 
> public
> facing E-Mail server, it is internal only.  Do I need this file?
> 
>> 
>> Now, set up the amanda user's .procmailrc rules like so:
>> 
>> :0:
>> * ^From.*no-reply at sns.amazonaws.com
>> |$HOME/retrieveArchive.tcl
>> 
>> :0:
>> *
>> ! heller at deepsoft.com
>> 
>> Voila!
> 
> Actually not.  Postfix is now using procmail, but procmail is not 
> processing
> .procmailrc...

My bad...no, you can skip the /etc/procmail recipe portion that calls 
spamc...you don't need that.

Comment/remove that bit, and then give it a go. Remember to issue 
"service postfix reload" after editing the main.cf file.
-- 
Mike Burger
http://www.bubbanfriends.org

"It's always suicide-mission this, save-the-planet that. No one ever 
just stops by to say 'hi' anymore." --Colonel Jack O'Neill, SG1