r4 - 03 Oct 2005 - 12:11:44 - BobKrzaczekYou are here: TWiki >  Help Web  >  ConfiguringCRM114 > ConfiguringProcmail
Tags:
create new tag
, view all tags

What Is Procmail?

procmail is a tool for processing mail as it is delivered to your account in the CIS mail system. It is a very powerful tool; most aficionados would try to convince you that procmail can do anything. In practice, it can't do everything, but it does make it super easy to

  • Automatically sort incoming mail into various folders.
  • Forward certain messages to another email address.
  • Run various programs and filters on each message, perhaps for spam filtering.
  • Respond automatically to incoming messages (perhaps to tell people you are on vacation)
  • Prevent certain kinds of mail (spam) from cluttering your inbox.
  • Write mail servers and mailing lists.
  • ... and so on. It's a very flexible tool, as you can see.

procmail is driven by a text file in your home directory; the contents of this file are known as procmail recipes and they direct procmail in exactly how and what to do to your incoming email. Because these recipes are somewhat cryptic, we've begun writing a small library of commonly requested actions. This library is discussed in the second part of this wiki topic.

Setting Up Procmail

Activating procmail for your email is easy. Just log into your CIS Unix account and run the following command in a shell. If you don't remember whether or not you've already set up procmail in your account, don't worry; it is safe to run this command multiple times. This will edit your .qmail and .procmailrc files in your home directory, and it will protect those files from any prying eyes.

mkprocmail

That's it, you're done! procmail is active for your email, now. If, for some reason, you need to disable its processing in your account, just run the following command instead.

mkprocmail off

Recipes

Someday, we'll have the time to write a good introduction to using procmail in your account. For the time being, through, we'll just include some links to web sites that have good documentation on it. However, don't overlook the library of recipes we've already written below; using those is even easier, since you don't have to write or understand procmail recipes.

The first source of documentation are the manual entries. Using the man command, look at the following entries.

  • man procmailex will show you all sorts of examples of simple procmail recipes you can use.
  • man procmailrc gives you the full syntax and definition of the ~/.procmailrc file that's hiding in your account.
  • man procmail gives an overview of the procmail system and how it actually works.

Offsite sources of documentation include:

All recipes for procmail go into a file named .procmailrc that resides in your home directory. Any line in this file starting with a # is considered a comment, and will be ignored. Your recipe file must contain the following two lines in order to work right here in the Center; if you used mkprocmail or a similar tool to create your recipe file, then these are already present. Otherwise, make certain that the following exist:

DEFAULT=$HOME/.mailbox
MAILDIR=$HOME/.mail

Everything listed below is added to your recipe file, below those existing lines.

Eliminate Duplicates

If you are on a mailing list, often times someone will reply to a message you post, which you then get twice (or more!) in your inbox. One copy was sent directory to you, the other copy was sent to the rest of the mailing list. Other times, people aren't certain which email address will reach you, so they send their message to every email they can think of. Sometimes, people don't realize that you already get mail under a certain aliases, so they needlessly send copies of an email to your account.

While generally harmless (if not a little rude), this gets annoying fast. Fortunately, procmail can help keep most duplicate messages out of your inbox. Just add the following line to your .procmailrc file, and your duplicates will be cut significantly.

INCLUDERC=/cis/share/procmail/noduplicates

CRM-114 Spam Filtering

See ConfiguringCRM114 for details on setting this up.

Vacation Messages

A vacation message is an email that is automatically sent when someone emails you on the 'net. Typically, you include a little bit of text that tells them you're on vacation and will read their mail when you return. With the vacation recipe provided here, you can control this just by sending yourself email messages, even from other domains (such as your Yahoo! or Gmail account. This is really handy when you're away on travel, at a conference, or similar places where you might not have your normal email environment available.

First, you need to select a password. This must not be your CIS password! Also, this should be a hard-to-guess password. Anyone who knows this password can control your vacation messages. If that "doesn't sound so bad," then stop and consider someone maliciously installing a horrible vacation message into your account on the same day you get email from your boss or relatives. Right? So, pick a good password.

Next, add these two lines to your .procmailrc file in your home directory. For this example, I've chosen thyashCov! as my password.

VACPASSWORD=thyashCov!
INCLUDERC=/cis/share/procmail/vacation

Now, anytime I'd like to turn on a vacation message, I'd send myself email like the following. The Subject: line will activate the vacation processor, and the entire body of the email will be used as the vacation message sent to everyone else. Don't use HTML or MIME email here; just use plain ol' text. Keep it simple!

To: myself@cis.rit.edu
Subject: vacation on thyashCov!

Hi!  I'm out of the office until October 31.  Your message has
been saved, and I will read it when I return.  If you require
immediate assistance with the Yoyodyne program, please contact
A. Helper at ahelper@example.com

Sincerely,
I. M. Gone,
Director of Molds, Spores, and Fungus Research,
RIT Dept of Rogue Biology

Now, when I get back from my vacation, I need to turn the message off. That's no problem, I simply send myself another message, this time with a Subject: line that disables my vacation message (note that the on has turned to off).

To: myself@cis.rit.edu
Subject: vacation off thyashCov!

I can type anything here, the body of this email doesn't matter.
All the magic happens in the Subject line.

Winmail.dat Attachments

Some people use the mailservers provided by ITS to send their email. One problem that keeps getting in the way is that the ITS mail servers keep rewriting any email attachments into a closed, proprietary format that can only be handled by Outlook mail clients. Those of us that don't use Outlook wind up receiving emails that contain mysterious winmail.dat file attachments. Until ITS fixes this problem, we have a way to get around the problem.

Simply add the following line to your procmail recipe file. After doing so, when the system sees an email for you that appears to contain a winmail.dat attachment, it will try to extract any attachments buried in it, and reattach them to your email. The original winmail attachment is still preserved, but your email will have whatever Word document, address card, image, or other attachment was buried in the winmail.dat attached as well.

INCLUDERC=/cis/share/procmail/winmaildat

Note that if you had the older recipe for processing winmail.dat attachments, you must delete it from your recipe file. Only the line shown above is valid.

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback