.procmailrc Documentation

Procmail is a mail-filtering program intended for use with Unix mail systems. The use of it was first suggested in the the inaugural offering of CS 115 to allow tutors to handle e-mail more easily and more efficiently. The existing 115 .procmailrc file sorts all incoming mail into one of several folders, and then forwards the message to a designated tutor for that folder. Currently, we have folders for each of the following categories:

  • Student Queries - General
  • Student Queries - Technical (i.e. Odyssey problems)
  • ISC Mail
  • Instructor Mail
  • classlist (mail sent by cs-marks)

Each of these folders (except classlist) has one or several tutors assigned to it, so that each tutor can deal with emails pertaining to a single topic.

Setting up procmail

The first thing you need to do is to open your .forward file (or create it if it doesn't exist) and add this line: |/software/procmail/bin/procmail

You can find your .forward file under /u/csXXX/; you should place your .procmailrc file in the same location. Once you have .forward ready, you can proceed to create .procmailrc, the file which will power your procmail setup.

The .procmailrc file

The .procmailrc file consists of two parts. It contains variable assignments which set the folders and tutor emails, and recipes/actions which handle the sorting and forwarding.

Assignments

The first two lines in your file should be the following assignments:

SHELL=/bin/sh
MAILDIR=${HOME}/mail
After these you can have as many folder/email assignments as you need. As an example:

# Folders:
STUDENTMAIL=${MAILDIR}/StudentGeneral
STUDENTTECH=${MAILDIR}/StudentTech
ISC=${MAILDIR}/ISC-mail
INSTRUCTOR=${MAILDIR}/Instr-mail
CLASS=${MAILDIR}/classlist

# Tutor emails:
TUTOR1=tutor1@student.cs.uwaterloo.ca
TUTOR2=tutor2@student.cs.uwaterloo.ca
ALL='tutor1@student.cs.uwaterloo.ca, tutor2@student.cs.uwaterloo.ca, tutor3@student.cs.uwaterloo.ca'
Note that the folder you specify must already exist.

Recipes/Actions

The next part of the file contains the recipes and actions. Most of these will follow this basic template:

:0:
* ^From.*pattern.*
{
    :0 c
    ! ${<a tutor email variable name>}

    :0
    ${<a mail folder variable name>}
}
where pattern can be any regular expression. This will search the From: line for addresses that match pattern, and then forward the message to whichever emails are assigned to the email variable specified. It then will save the message into the folder assigned to the given folder variable.

(If you would like to search for pattern in the body of an email and not just the From: line, change the first line in the above recipe from :0: to :0 H B :. This will search both header and body.)

As with assignments, you can have as many recipes as you want. Remember, though, that the first recipe to match is the one that is applied, so order is important.

For more details on how the .procmailrc file is constructed, see man procmailrc and man procmailex.

-- HumaZafar - 27 Apr 2009

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2009-05-27 - TerryVaskor
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback