Using Procmail on the Nevis mail server
Short version
Look at
/a/mail/procmailrc/seligman
. Edit your own
/a/mail/procmailrc/$USER
and include/edit the recipes from my file to suit your needs.
Why bother?
Why should I bother configuring Procmail on the Nevis mail server? The mail reader on my laptop (e.g., Thunderbird
, Apple Mail
, Outlook
) already has a mail filter.
- Speed: The mail server is faster at processing your email than your laptop/desktop.
- Configuration: In general, Procmail provides a greater level of control than your mail reader. (Boast: It certainly provides a greater level of control than Gmail or Columbia's LionMail.)
- Multiple devices: If you read your mail on different devices (e.g., your laptop, a desktop, your phone) then the Procmail rules will apply to all your incoming mail. If you set up mail filtering on Apple Mail on your laptop, that will have no effect on mail you receive via the Mail app on your iPhone.
Using Procmail
Procmail
is a program that delivers your mail. You can create a file
/a/mail/procmailrc/$user
to filter messages, automatically direct mail into certain folders, and other advanced operations.
There are two places where you can put a procmail command file:
/a/mail/procmailrc/$user
or
~/.procmailrc
. The former location is preferred, since the file will remain available to the mail server if your home directory becomes unavailable; e.g., if your
group's server goes down. The latter name is the standard for many computer systems, and it's allowed at Nevis though I don't suggest it. If you have both files, they will both be executed.
If you glance at
/a/mail/procmailrc/seligman
or at the example below, you'll see that using procmail requires learning a new scripting language. The constant
:0
seems a bit off-putting, until you learn that in an early version of the language you were required to use
:N
where "N" was the number of lines in the recipe; that's no longer necessary, but you still need
:0
to maintain consistency.
Also, procmail makes heavy use of
regular expressions
. That is natural, since regular expressions (or just "regexes") are frequently used in searching and processing text, which is fundamental in handling mail.
A practical example.
Reminder from the
Mail Filters page: Every time a
LArSoft
developer makes a change to the
LArSoft git repository
, I get an email message from
larsoftcommit@fnal.gov
or
uboonecommit@fnal.gov
. Frequently I get dozens of such emails every day. I don't want to automatically delete them, since there may be something that impacts my work, but I don't want them cluttering my INBOX either.
So I use a mail filter to test if the "From" address of each email I receive includes
larsoftcommit@fnal.gov
or
uboonecommit@fnal.gov
. If it does, the mail is immediately sent to my
LArSoft commit
folder instead of my INBOX. Periodically I review the contents of that folder to see if any code changes are relevant to me.
If you look in
/a/mail/procmailrc/seligman
, you'll see this code to implement the filter:
:0
* ^TO_.*(larsoft|uboone)commit\@fnal\.gov
{
:0:
"LArSoft Commit"
}
References
If you're interested in exploring procmail, I recommend the following resources: