From Wiki

Jump to: navigation, search

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.

:0 c:
* ^(To|Cc|Delivered-To): .*root@(|localhost)
#This command above - will copy all emails sent To|Cc|Delivered-To into a Maildir folder called Root-Server.

* ^(To|Cc): .*
#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: .*
* ^To: .*
#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

Procmail Examples


man procmailex

Excellent Article:


Personal tools