Procmail is controlled via the .procmailrc file in your home directory. Even if you will probably find it most convenient to manage .procmailrc from the Procmail module in Usermin, the starting point for these examples are the actual Procmail "recipes".
This is what .procmailrc may look like:
LOGFILE=${HOME}/.usermin/procmail/log :0wf | /usr/bin/spamassassin :0: * ^X-Spam-Status: Yes mail/spam SPAMWORDS=mortgage|onlythebestbabes\\.com :0HB: * $$SPAMWORDS mail/spam :0w * ^(To|Cc|Received):.+oldaddy@example\.com | /etc/smrsh/autoreply.pl ${HOME}/autoresp/oldaddy.txt :0c * ^(To|Cc|Received):.+support@example\.com ! john.smith@example.net |
Below follow some comments to the various recipes. You may want to (temporarily) replace your .procmailrc file with the above file while reading this page. That way you can see what it looks like via the web interface in Usermin's Procmail module.
LOGFILE=${HOME}/.usermin/procmail/log
That line makes Procmail update the file log with its actions. By using just that path and filename, the log file will be "rotated" automatically once a week, which prevents that the file grows too big. The rotation program keeps files for the last four weeks as log.1, log.2 etc.
See the Procmail docs if you want to modify what gets written to the log file.
:0wf | /usr/bin/spamassassin
It's this recipe that tells Procmail to have all messages classified through SpamAssassin, which adds some message headers and possibly labels the message as spam by prepending [SPAM] to the "Subject:" header.
:0: * ^X-Spam-Status: Yes mail/spam
If you don't want that the spam messages end up in your ordinary mailbox, you need to tell Procmail what to do instead. This recipe makes messages that SpamAssassin identified as spam be stored in the spam folder, which can be conveniently managed from Usermin.
If you come to trust SpamAssassin well enough, you may want to have Procmail trash the spam instantly instead. This is a recipe for doing so:
:0 * ^X-Spam-Status: Yes /dev/null
SPAMWORDS=mortgage|onlythebestbabes\\.com :0HB: * $$SPAMWORDS mail/spam
If you find that SpamAssassin fails to identify certain spam messages, you can have Procmail filter them based on whatever you like. This example assumes that messages that contain the string mortgage or the string onlythebestbabes.com are spam, and such messages are stored in the spam folder.
:0w * ^(To|Cc|Received):.+oldaddy@example\.com | /etc/smrsh/autoreply.pl ${HOME}/autoresp/oldaddy.txt
Let's assume that you previously used the email address oldaddy@example.com, but that you gave it up due to too much spam. Since people that you want to be available to may still have that address in their address books, it may be a good idea to have Procmail send an automatic message that explains how to get in touch with you. This recipe makes Procmail send an automatic message if it finds the string oldaddy@example.com in any of the "To:", "Cc:" or "Received:" message headers. The recipe assumes that you have an autoresp subdirectory in your home directory with the file oldaddy.txt, which contains the contents of the automatic message.
In this case you never see the original message to your old address. If you want to send an automatic message, while the original message still ends up in your mailbox, you just add the c flag to the "colon line" (see the FAQ).
See below for further details about autoresponders.
:0c * ^(To|Cc|Received):.+support@example\.com ! john.smith@example.net
Assume that you are upholdning some kind of support service together with another person, so you want that when a message arrives to the address support@example.com, a copy is forwarded to the other person's mail account. This recipe forwards a copy to john.smith@example.net.
Even if the above comments don't cover all the details in respective Procmail recipe, it should be emphasized that every single character (almost) is important. To become a happy Procmail user, you should also study some of the Procmail docs, such as the FAQ and the Quick Reference Guide.
/etc/smrsh/autoreply.pl sends a message based on information from the original message and the autoreply file as specified in the Procmail recipe.
By default, autoreply.pl writes the necessary message headers. If you like, you can replace one or more of the default headers with headers that you specify in the autoreply file:
Subject: Address oldaddy@example.com no longer valid From: Andy Jones <newaddy@example.com> [body of message begins here] |
You can also set additional headers that way.
autoreply.pl includes a feature, so that when an automatic message has been sent to a particular address, the program won't send further messages to that address until after a certain period has passed. By default, the waiting period is 7 days, but you can specify a shorter or longer period via the special "Reply-Period:" message header in the autoreply file:
Reply-Period: 3
You may not set a shorter waiting period than 1 day. (If you would try, autoreply.pl would apply the default 7-day period.)
By default, the info per sender, about when an automatic message was last sent, is stored in the DBM database /home/username/autoreply_tracking. If you for instance want to keep up with previous replies separately for each autoresponder, you can use the autoreply file, via the "Reply-Tracking:" message header, to set some other filepath.
There are a few variables that can be used in the autoreply file for including parts of the original message in the automatic message. They are: $SUBJECT, $FROM, $TO, $DATE and $FULLHEADERS.