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 :
- “man procmail” for standard Unix manual.
- On Linux servers, /usr/share/doc/procmail-3.22/ (may be other version instead of 3.22) – FAQ, examples etc. that comes with installation.
- Official procmail site http://www.procmail.org/
- Search for “procmail manual” in Google. For example, good manual found: http://userpages.umbc.edu/~ian/procmail.html
Using procmail on CS unix servers:
- Create directory .procmail in your home dir: mkdir ~/.procmail
- 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.
- 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 firstname.lastname@example.org save to file $MAILDIR/junk-mail) :
* ^From:.* email@example.com
- To filter mail send to specific address (example: To CS-ASSIST-L@TECHUNIX.TECHNION.AC.IL save to file $MAILDIR /assist-list folder:
* ^To:,* CS-ASSIST-L@TECHUNIX.TECHNION.AC.IL
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
You can use Regular Expressions to specify exactly what you want to filter.
More examples can be found in procmail documentation.
- To activate procmail on your incoming mail you need to create file ~/.forward in your homedir and add the following line:
“|IFS=’ ‘ && exec /usr/bin/procmail -f- || exit 75 #your-username“
Replace your-username with your username, and include the quotes in the 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.
Please notice that you cannot use vacation utility with procmail activated.
To use vacation, please see Configuring Vacation Mail With Procmail