![]() |
|
|||||||||||||||||||||||||
|
|
About Procmail
Table of ContentsWhat is Procmail?Procmail is a free open-source program that runs on top of your regular mail client (e.g. elm, pine). USES: creating mail-servers, mailing lists, sorting incoming mail into separate folders/files (real convenient when subscribing to lists), preprocessing your mail, starting any programs upon mail arrival (e.g. to generate different chimes on your workstation for different types of mail) or selectively forwarding certain incoming mail automatically to someone. This is a basic tutorial to get you started, but with a little research on your part, you can use Procmail to do much more.Procmail tutorials: Bug reports should be sent to bug@procmail.org How to Setup Procmail1. Modify your .forward file Incoming mail to your account will always check first for a .forward file before going to your mail directory. If one is found, then anything in the file will be executed first. If you would like for Procmail to handle your mail sorting, then add this line to your .forward file(create one if you don't have one). "exec | procmail" (with double quotes) 2. Create .procmailrc After you have added the exec command to your .forward, you need to tell Procmail what to do with your mail. This is done in the .procmailrc file(that you will create)through the use of "recipes." .procmailrcThe easiest way to configure procmail is to just put your recipes right in your .procmailrc file. The .procmailrc file must be located in your home directory, but other than that you may sort your mail to any directory path you choose.The first line in the file tells procmail where its logfile is located. This is what mine looks like: LOGFILE=$HOME/Procmail/log So, my logfile is located in a directory called Procmail, which is in my home directory, and the file itself is called log. The next line in the .procmailrc file sets the procmail MAILDIR environment variable to the directory of where your mailboxes are stored. If you use elm and pine, then set your MAILDIR like this: MAILDIR=$HOME/Mail You can also add the line VERBOSE=no to minimize logging and save space. Finally, you add your recipes. Procmail RecipesA Procmail recipe is a set of conditions that, if met, order the specified action to be executed. In Procmail, regular expressions are used in the conditions of a recipe to, for example, look for a pattern in the Subject header of a message.A recipe always begins with a line with :0: on it. The next Line(s) specify the conditions to be met, and the last line is the action to take place. Here is a good one to use for testing:
:O: Replace "username" with your username and save and exit the file. Test the recipe out by sending an email to yourself (From within the system so that your username matches and satisfies the recipe condition). Then check your folders to see is there is now one called IN.testing with the email you just sent in it. Now you can create recipes to sort your mail however you like. You can even sort mail directly to the "trashbin." Say, for instance, you never want to read anything Sprague has to say to you: This recipe will delete all mail sent to you from user "sprague":
:0: If you are on a mailing list then you might want to sort all mail from that list into its own folder-- or you could sort mail from multiple lists all into one folder. E.g., if you are on both the cyberlaw@cs.fsu.edu and cop4531@cs.fsu.edu lists, then you could sort all mail from those lists into a "classes" folder like this:
:0:
See also the section Using the Extraction Operator and $MATCH to Sort
Mailing List Messages in Recipe Metacharacters
The difference between a word and a string: If you search for the string test, then procmail searches for any occurrence of those characters in that order, including within other strings. If, on the other hand, you told it to search for the WORD test then it would only look for exactly that string by itself. For example: The STRING test would be found in the heading Subject: testing but the WORD test would not. It would, however, be found in Subject: test! One more thing: A word can only contain letters, digits, and underscores, so any whitespace or other characters(such as the ! above) serve as delimiters.
MailstatYou can use mailstat to track your incoming messages, including any errors that occurred in processing your mail, how many emails you have recieved since the last time you ran mailstat, and where procmail has sent them. You must run mailstat from Diablo.To get help on mailstat, type: mailstat -h To run mailstat, type: mailstat $HOME/Procmail/log Where $HOME/Procmail/log is the value of your LOGFILE variable in .procmailrc. Running the command moves your log file to log.old and displays a tabular description of your log similar the following: Total Number Folder ----- ------ ------ 9964 4 IN.testing 3408 1 classes ----- ------ 13372 5 Unless you delete your logfile from time to time it will keep growing larger and larger.
|
|||||||||||||||||||||||||
|
|
Comments and questions should be sent to help@cs.fsu.edu. |