University Systems --> Glue --> E-mail on Glue --> Filtering Incoming E-mail on WAM / Glue using Procmail -->

Filtering Incoming E-mail on WAM / Glue using Procmail

Important note:

There is a known problem on Workstations at Maryland (WAM) and Glue with using procmail to sort mail into folders. Procmail does not properly use the file locking mechanism that is used on WAM and Glue. This means that there is a significant chance that some of your mail will be lost if you use procmail to sort mail into folders. The Office of Information Technology (OIT) Help Desk recommends against using procmail to sort mail on WAM or Glue. Procmail does work adequately for deleting unwanted incoming mail (sorting mail into /dev/null)

procmail is a mail filtering available on the Glue and WAM Unix computer system. You can set it up using the following instructions.

  1. Change to /mail/<USERID> directory by typing in at the command prompt:
    cd /mail/<USERID>
    
    Where <USERID> is the log in ID for your Glue or WAM account.
  2. Open up .forward in your favorite editor:
    pico .forward
    
  3. put just the following into it (The quotes are important):
    "| procmail -tf- "
    
  4. Close it up, and save it. In pico this can be done with the control-x key combination and answering yes to save it.
  5. Open up .procmailrc in your favorite editor:
    pico .procmailrc
    
  6. Start it off with this:
    VERBOSE=off
    MAILDIR=/mail/<USERID>/
    LOGFILE=/mail/<USERID>/log
    PATH=/usr/local/procmail/bin;/bin;/usr/bin
    COMSAT=on
    

    Note: We recommend that you only use the log file when you have created a new filter or if you need to debug a problem. This is due to the large volume that the log file can accumulate, depending on the volume of mail that you receive. To turn off the log file, simply place a "#" in front of the LOGFILE line in your .procmailrc file. To use the log again, just remove the "#" from the LOGFILE line.

  7. Now you want to add the filters to let you do some sorting.

    Let's set one up that any mail from yourself will go into a folder called self. You would add the following to .procmailrc file:

    :0:
    * ^From.*<USERID>
    /mail/<USERID>/self
    
  8. On most Glue and WAM accounts procmail can only write to the /mail/<USERID> directory. If you want pine to be able to read mail in these mail folders you'll have to create a link to where pine expects its mail. Type in the following command to create the link:
    ln -s /mail/<USERID>/self ~/mail/self
    
    Now when in pine, you will see a folder called self in the folder list.
  9. If you want to have mail from a particular source automatically discarded, use /dev/null (the standard name for the "bit bucket") instead of a folder name:
    :0:
    * ^From.*<unwanted-address>
    /dev/null
    
  10. More can be added here, including some anti-spam measures too. Procmail's man pages can be helpful here. To get at them, type in:
    man procmail
    man procmailrc
    man procmailex
    

    The procmailex man page is examples of various procmail filters.

How do I:
How are we doing? Comments on this page?
Office of Information Technology
Office of Information Technology Help Desk Web Site University of Maryland Web Site Office of Information Technology Web Site