====== Procmail ====== ====== Procmail - Mail Filtering ====== Procmail is a Mail processor which can forward, sort, or just about do anything with emails. Procmail is mainly a USER run program, where users determine what they want sorted etc. etc. The users procmail script is located in /home/$USER/.procmailrc Lets write a basic Procmail script: vi /home/$USER/.procmailrc #Start of Procmailrc script. PATH=/bin:/usr/bin:/usr/bin:/usr/local/bin/o2sms MAILDIR=$HOME/Maildir LOGFILE=$MAILDIR/procmail.log :0 c: * ^(To|Cc|Delivered-To): .*root@(server.com|localhost) .Root-Server/ #This command above - will copy all emails sent To|Cc|Delivered-To root@server.com into a Maildir folder called Root-Server. :0: * ^(To|Cc): .*debian-security-announce@server.org .Debian-Security-Announce/ #This command will MOVE/Put all emails sent To|Cc the debian-security-announce mailing list, into a folder called Debian-Security-Announce :0 c: * ^From: .*nagios@external.server.com * ^To: .*user@server.com .Test_Folder/ #This command will copy emails which are From and To the various users. Once these 2 criteria are met, then the email is copied into the Test_Folder. There is a load more commands and checks which procmail can carry out. It can run a virus scan and spam check on some, or all of your email. The : means lockfile while processing. man procmailrc #shows all options ===== Forward a Copy of all Emails to another email account ===== Although it is possible to do this using the /home/$user/.forward, it is as easy to do this with a procmailrc entry. :0 c !email@gmail.com ===== Procmail Examples ===== Simple!: man procmailex Excellent Article: http://www.debian-administration.org/articles/242 Links: http://www.redhat.com/docs/manuals/linux/RHL-7.2-Manual/ref-guide/s1-email-procmail.html