
The required files are contained in a tarfile (an archive file) called procsetup.tar. The UNIX "tar" command extracts these files to your UNIX account:
.procmailrc .procmail/ (a subdirectory)
and in the .procmail subdirectory:
.procmail/rc.testing .procmail/rc.maillists .procmail/rc.vacation .procmail/vacation.msg (sample vacation message)
Caution: Any existing files with the names listed above will be overwritten without warning when you extract the tar file. To preserve such files, rename them or move them to a different subdirectory.
To obtain the setup files, log on to your central UNIX account and type the following commands:
cd tar -xvf /www/htdocs/evelyn/procsetup.tarSee instructions in the remaining sections of the Web document "Procmail: Instructions" to find out how to test your .procmailrc setup, and how to customize and use the mailing list and vacation recipes included in the package.
mkdir .procmailat the UNIX % prompt.
# Comment: Set VERBOSE=on in next line when debugging. VERBOSE=off # Replace "mail" with the name of your mail directory. # If you use Pine, your mail directory is called mail. # This directory must exist before you start using procmail. MAILDIR=$HOME/mail # Directory for storing procmail log and rc files PMDIR=$HOME/.procmail LOGFILE=$PMDIR/log # Next line for testing. Add # at beginning when not needed. INCLUDERC=$PMDIR/rc.testing # To sort mailing list mail to a folder, remove # from next line. #INCLUDERC=$PMDIR/rc.maillists # To send vacation message, remove # from next INCLUDERC line. # In most cases, next line should be last in this file. #INCLUDERC=$PMDIR/rc.vacationNote: The two INCLUDERC lines near the end of the sample file above show how and where you would include command files to file mailing list messages and send a vacation message. In the sample above, the # signs preceding INCLUDERC make these lines comments so they are ignored by procmail. See details on the rc files in the section on Creating and testing special-purpose recipes. Remove the # symbol from the beginning of each of the two lines once you have created those files, to allow procmail to run them.
Follow these step-by-step directions:
# Procmail recipe to send mail whose Subject: line contains # "test" anywhere to the mail folder IN.testing :0: IN.testing.lock * ^Subject:.*test IN.testing
Note: The Usenet Filtering Mail FAQ and other procmail documentation tell you to set up a .forward file in your home directory. On the University of Delaware central UNIX systems, in order for this recipe and others to work as expected, do not use a .forward file on your account.
|
|
|
|
| :0: IN.testing.lock
|
Begin recipe line (one per recipe)
|
|
| :0 | Begin new recipe | |
| : | Use lockfile | |
|
IN.testing.lock
|
|
|
| * ^Subject:.*test
|
Condition line
|
|
| * | Begin condition | |
| ^Subject: | Match "Subject:" at beginning of line... | |
|
.*test
|
|
|
| IN.testing
IN.testing |
|
Action line (one per recipe)
Put message in mail directory folder IN.testing |
^TOusernamewhere both letters in TO are capitalized and there is no space between TO and the "username" to be matched. This format applies only to the "To:" header line.
! userid@host.domain
For example:
! username@udel.eduDo not specify a lock file when you send mail via the action line - the system locks mail files as needed. The "begin recipe" line should read :0
INCLUDERC rc.urgent_mailAny time you change your .procmailrc file, you should test to make sure it is still working properly. Remove the # symbol at the beginning of the
INCLUDERC rc.testingline and send yourself another set of test messages, with and without the word "test" in the Subject line, and with appropriate combinations of specific conditions to check for, as called for in your new recipe(s). You may not be able to test a recipe that processes mailing lists until you receive messages from the lists you are subscribed to.
Once you are satisfied, comment out the rc.testing line in your
.procmailrc file by adding a # symbol at the beginning of that line.
AND
If you would like procmail to take an action only if incoming messages meet all conditions in a set (AND), write each condition on a separate line preceding the action line. If any of the ANDed conditions could also be met individually by other recipes called by your .procmailrc file, INCLUDE the recipe with the more restrictive conditions (the recipe with multiple conditions) first.
The following rc file (rc.edstatsoft) sends all EDSTAT-L messages with the word "software" anywhere in the Subject: line to a file called IN.edstat.software.
:0: IN.edstat.software.lock # Is this an EDSTAT-L message? * ^TOedstat-l # Does the Subject include "software"? * ^Subject:.*software # If both conditions met, deliver to folder listed next: IN.edstat.softwareIf the .procmailrc file INCLUDEs an rc file that redirects EDSTAT-L messages more generally to a different folder, the two rc files must be INCLUDEd in the correct order for the appropriate filtering to take place. The sample .procmailrc file INCLUDEs the rc.maillists recipe which files EDSTAT-L messages in the mail folder IN.edstat (see "Recipe for filing messages from mailing lists" below). In order for the rc.edstatsoft recipe to be processed first, so it can selectively redirect EDSTAT-L messages referring to software to the mail folder IN.edstat.software, the INCLUDERC commands in .procmailrc must be ordered as follows:
... INCLUDERC rc.edstatsoft INCLUDERC rc.maillists ...OR
The following methods illustrate different ways of setting up OR conditions.
:0: student.work.lock * ^Subject:.*(quiz|test) student.workNotice that the same action line applies to either condition.
The following recipe allows you to file mailing-list messages separately from the rest of your mail. For this example, assume that you are subscribed to EDUCOM's Edupage and to a list on teaching statistics called EDSTAT-L. You would like to file mail from Edupage in a folder called IN.edupage and messages from EDSTAT-L in a folder called IN.edstat, both in your mail directory. Create a new rc file called rc.maillists in your .procmail directory and put both recipes in the same file, as follows:
:0: IN.edupage.lock # Next line checks the To: line for edupage. * ^TOedupage IN.edupage :0: IN.edstat.lock
# Next line checks the To: line for edstat-l * ^TOedstat-l IN.edstat
The vacation recipe rc.vacation, adapted from the procmail man pages (man procmailex), sends an automated response (vacation.msg) to your correspondents while you are away from your mail, delivers your mail as usual, and records the sender's e-mail address in the file vacation.cache in your mail directory.
The sample .procmailrc file contains an INCLUDERC line for the vacation recipe. To activate the recipe:
When you return to your mail:
The vacation recipe and message files
Create the file rc.vacation in your .procmail directory and insert the code shown below, replacing "username@udel.edu" with your complete e-mail address. Some comment lines are included for clarity.
:0 Whc: vacation.lock # The three (ANDed) conditions address the following: # Reply if mail is addressed to me. # Don't reply to daemons or mailing lists (! = not). # Avoid mail loops (don't reply to mail I might send myself). * $^To:.*\<$\LOGNAME\> * !^FROM_DAEMON * !^X-Loop: username@udel.edu # Store sender's address in vacation.cache if not there already. | formail -rD 8192 vacation.cache # If sender's address not in cache (e=previous recipe failed), send # mail containing vacation message. Note: Trailing backslashes (\) # required to denote continuation of single action line. :0 ehc | (formail -rA"Precedence: junk" \ -A"X-Loop: username@udel.edu" ; \ cat $PMDIR/vacation.msg \ ) | $SENDMAIL -oi -tUse a UNIX text editor such as pico to create the file vacation.msg in the .procmail directory. This file should contain the vacation message you would like your correspondents to receive. The message could contain text like the following, where you replace returndate with the appropriate date:
I will be away from my mail until returndate. Your message will be read when I return.
The mailing list and vacation recipe files are already INCLUDEd, but inactive, in the sample .procmailrc file. To activate these recipes, remove the # symbol before the corresponding INCLUDERC lines:
INCLUDERC=$PMDIR/rc.maillists INCLUDERC=$PMDIR/rc.vacationThe rc.vacation recipe should send you an auto-reply the first time, and only the first time, you send yourself mail. By the same token, your correspondents will receive just one vacation message from you in your absence.
Procmail Instructions: Table
of Contents
Main Procmail
page
[Help Center]
Technology
Home Page
University of Delaware
Home Page