Ключевые слова:mail, procmail, (найти похожие документы)
From: Chad Ziccardi
Subject: Пример автоматического разбора почты через procmail (eng)
procmail - a simple example
procmail is a tool for manipulating mail. If you like to sort your
incoming mail into various folders/directories, procmail can do that
for you. If you want to cut down on the spam, procmail can help with
that. Basically, if you can write a rule for it, procmail can do it.
I wanted to sort incoming mail for a list archive box. Mail for one
list had to go to one mailbox and from another list for another
mailbox. This seemed pretty easy to do with procmail.
The home page for procmail is http://www.procmail.org/.http://freshports.org/port-description.php3?port=2177 a link to procmail in FreshPorts.
And I used some of this http://mirror.ncsa.uiuc.edu/procmail-faq/faq.html#1 FAQ.
But Timo's (http://www.uwasa.fi/~ts/info/proctips.html) procmail tips and recipes was
very useful once I started creating my procmail rules.
The first step was to install procmail from the ports. I followed the
instructions found in the FreeBSD handbook for compiling ports
from the internet.
Don't do a make clean until after you grab the examples during the
configuration later in this article
I'll give you a very simple example. procmail is often invoked from
your .forward file. .forward resides within your home directory. It
is used by sendmail, and other mail transport agents (MTAs).
.forward, if it exists, is used each time a new message is delivered
to that user. The conventional use of .forward is for redirecting
mail. See man forward for more information.
procmail makes use of .forward to process your mail according to the
rules you specify within .procmailrc.
Here is what I put in ~/.forward:
[dan@set:/home/dan] # more .forward
"|exec /usr/local/bin/procmail || exit 75"
The above is taken from man procmail, in the NOTES section. Be sure
to include the quotes.
Here is the example rule set I'm using. This example was taken from
Your procmail version may vary so the above directory may differ on
[root@set:/home/dan] # more .procmailrc
# Please check if all the paths in PATH are reachable,
# remove the ones that are not.
MAILDIR=$HOME/mail # You'd better make sure it exists
:0 # Anything from Henry
henries # will go to $MAILDIR/henries
:0 # anything from cvs-all mailing list
lists/cvs-all # will go into my archive
# Anything that has not been delivered by now will go to $DEFAULT
# using LOCKFILE=$DEFAULT$LOCKEXT
Be sure to create the mail directory indicated above:
That should be about it. Try it and see.
Sometimes it can be difficult to test your procmail rules. You can't
always wait for a mail message which meets your test conditions.
Fortunately, there is another way. Take a message, including the
headers, and copy it to a file. Then pipe the contents of that file
to procmail. I found the testbench as described at Timo's
procmail tips and recipes very helpful.
Remember to do a make clean!
Gill wrote in with this recipe for mailing lists. It was actually
written by Neil Blakey-Milner.
I am sure you will get hounded with people suggesting thier own
procmailscripts, but this one came to me by way of the -questions
list and it is the niftiest one i've ever seen and it works
perfectly. It is useful for
all of the FreeBSD lists:
# From: Neil Blakey-Milner
# Cc: email@example.com
# Subject: Re: Procmail recipes for fbsd lists
# I use:
# It can probably be simplified, but it expands as necessary when I
# join new lists, &c.
Chad Ziccardi wrote in with these two URLS: