CS Unix mail – procmail utility for mail filtering

 

PLEASE NOTICE: From 20/9/2022 access to CS Unix mail is possible only from inside Technion network (CS or Technion SSLVPN)

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:

LINEBUF=4096
VERBOSE=off
MAILDIR=$HOME/mail
FORMAIL=/usr/bin/formail
SENDMAIL=/usr/sbin/sendmail
PMDIR=$HOME/.procmail
LOGFILE=$PMDIR/log
INCLUDERC=$PMDIR/rc.maillists

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) :

:0:
* ^From.* junk@somewhere.co.il
junk-mail

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

:0:
* ^To:,* CS-ASSIST-L@TECHUNIX.TECHNION.AC.IL
assist-list

The above recipes have the following format:

:0:
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
:0:
* ^(From|Cc|To).*staff
staff-mailbox

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:

|/usr/bin/procmail

 

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.