Configuring procmail


Configuring procmail

Let's see...two messages from the boss...17 messages from the string collector's discussion group...oh, hey, a message from mom...and....

One of the handiest things you can do to make your Unix life easier is to use procmail (a mail-filtering program) to automatically handle some of your incoming email.

In this section, we'll show you how to configure procmail so you can manage incoming messages. As Figures 11.16 and 11.17 show, you need to do two things to set up your system to manage mail with procmail:

  • Specify settings for procmail (Figure 11.16). For example, incoming mail normally gets plunked directly into your in-box; however, procmail filters mail before it even gets to your in-box, so you need to tell procmail where your mail folders are, among other things.

  • Tell procmail to do its thing (Figure 11.17). Essentially, you create a .forward file that sends your incoming mail to procmail for processing before you ever see it. This step is not necessary for many systems, particularly newer Linux and Unix systems.

    Figure 11.16. You specify the procmail settings you need, and then you're off and running.

    Figure 11.17. Tell the Unix system to send incoming messages to procmail for processing to ease your mail management.

To specify settings for procmail:

1.

pico ~/.procmailrc

To begin, access your editor and create a .procmailrc file in your home directory.

2.

LOGFILE=$HOME/.maillog

Give procmail a place to log all of its activities, so it can tell you what it's done: "I threw away 7 messages from your boss... filed 3 messages from Joe in the GolfBuddies folder...." In this example, we tell procmail to keep a log file called .maillog in our home directory (Figure 11.16). Keep an eye on this file, because it can grow large over time.

3.

PATH=/usr/bin:/usr/local/bin:/bin

Specify the path for your executable programs. It's a good idea to do this now, just in case you eventually use procmail to more extensively filter or autorespond to messages.

4.

DEFAULT=/var/spool/mail/yourid

Specify the location for your incoming mail. Remember, the filter gets the mail before it ever reaches the in-box, so you need to tell procmail where your in-box is. Check with your system administrator to confirm the DEFAULT. (/var/spool/mail /yourid is typically, but not always, the location, but obviously with your real userid, not yourid.)

5.

MAILDIR=$HOME/mail

Specify where procmail should find your mail program and all the folders and information it creates. If you're using pine, you will probably type this line exactly as shown. If you're using mutt, you might need to use Mail instead of mail.

To turn on procmail filtering:

1.

pico ~/.forward

Use your favorite editor to create a .forward file in your home directory.

2.

"|IFS=' ' && exec /usr/bin/procmail -f- || exit 75 #yourid

Enter the text exactly as shown, but substitute your userid for yourid above (Figure 11.17). If procmail is not located at /usr/bin, type in the actual location. /usr/local/bin would be another likely directory.

3.

Save and close the file.

That's it! Now all you have to do is wait for incoming messages and see if they get filtered as you intended (as you'll set up in the next section).




Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net