These instructions are for getting Procmail to work. I spent an entire day trying to get Procmail to do something, anything. Eventually I found that Procmail is, contrary to first appearances, simple to use for simple tasks.
touch ~/.procmailrcEdit the file so it looks like this:
# Turn on detailed logging so we can see what happens. VERBOSE=on LOGFILE=/home/phil/procmail_log # Move mail in the new mail file '/var/spool/mail/phil' to the # '/home/phil/Mail/testing' mail file, if the subject is 'testing'. # If the 'testing' mail file doesn't exist, it is created # automatically. :0: * ^SUBJECT.*testing /home/phil/Mail/testingThis will move new mail to the 'testing' mail file, if the subject is 'testing'. Mail files are plain text files containing mail text. Remember to substitute your username for 'phil', which is my username on my Red Hat Linux 7.0 system.
The lines beginning with '#' are comments and they are ignored. The line starting ':0' indicates the beginning of a rule, or 'recipe'. The second colon makes Procmail create a lock file. The lock file prevents other programs from writing to the incoming mail file while Procmail is working on it. This is a good thing.
The '*' indicates the beginning of a condition. The condition is written as a 'regular expression'. The condition is "look starting at the beginning of the line for 'SUBJECT', followed by zero or more of any characters, then the word 'testing', then zero or more of any characters." The condition is case insensitive.
If the condition is met, then the message is moved to the mail file '/home/phil/Mail/testing'.
Save changes and quit. The file must be in Unix text format. Procmail doesn't understand MS-DOS text format line endings.
cat /home/phil/Mail/testingRemember to replace 'phil' with your username. You should see something like this:
From phil Wed May 9 12:35:36 2001 Return-Path:Notice how Procmail has picked up the word 'Subject' at the beginning of one of the lines, followed by zero or more of any characters, then the word 'testing', then zero or more of any characters. Next have a look at the 'testing' mail file with your mail reader, and you should see your test message in there.Date: Wed, 9 May 2001 12:35:36 +0100 From: Phil Message-Id: <200105091135.f49BZa902253@localhost> To: phil@localhost Subject: testing It worked!
[.]quit [0]reset [*]color [/]progs __ unknown !! not supported RegExp emacs : RegExp gawk : RegExp grep : RegExp perl : RegExp php : RegExp python: RegExp sed : RegExp vim : .oO() [1-2]: start to match: 1) on the line beginning 2) in any part of the line