Unix procmail utility for mail filtering

Procmail is a highly configurable mail filtering utility for Unix mail .
It can automatically put certain email in specified mailboxes/folders.
This guide is intended to assist the user to start using procmail as quickly as possible for mail filtering on CSA/CSD .

Documentation for procmail :
Using procmail on CS unix servers:
  1. Create directory .procmail in your home dir: mkdir ~/.procmail
  2. Edit file .procmailrc in your homedir and add the following lines:


Please notice that MAILDIR  is set to the dir where you keep your mailboxes/folders. In this example its set to ~/mail .Change it to what ever is your dir for mail mailboxes/folders.


  1. In file ~/.procmail/rc.maillists you should define the filters that are needed.
    • To filter mail from specific destination that arrives to your Inbox and save it in a file, add the lines (example: From junk@somewhere.co.il save to file $MAILDIR/junk-mail) :

* ^From.* junk@somewhere.co.il

  • To filter mail send to specific address (example: To CS-ASSIST-L@TECHUNIX.TECHNION.AC.IL save to file $MAILDIR /assist-list folder:


The above recipes have the following format:

zero or more conditions
one action line

The idea is that if the conditions are met, the action is performed.

Example: Any mail to/from/cc mail group “staff” that arrive to you, will be put in mailbox staff-mailbox

# Put mail from staff mailing list into mailbox staff-mailbox
* ^(From|Cc|To).*staff

You can use Regular Expressions to specify exactly what you want to filter.
More examples can be found in procmail documentation.

  1. To activate procmail on your incoming mail you need to create file ~/.forward in your homedir and add the following line:



Now procmail is activated on each mail arrives to your CSA/CSD account. You can see in ~/.procmail/log  file what happened to each mail that arrives.

To disable procmail, move/delete .forward file.