Excerpts from [procmail]: Adding a new header and then some. by Jorgen Pehrson
DATESTAMP=`date +"%m%y"`
FYI, if you want to be efficient, it's possible to construct $DATESTAMP by
parsing information from the "From " header.
# Get current month from the From_ header.
:0
* ^From [^ ]+ +... \/...
{ MONTH = $MATCH }
# Get current year from the From_ header.
:0
* ^From [^ ]+ +... ... ?[0-9]+ [0-9]+:[0-9]+:[0-9]+ \/[0-9]+
{ YEAR = $MATCH }
# Convert three-letter month abbreviation to a number.
MONTHS = "Jan01Feb02Mar03Apr04May05Jun06Jul07Aug08Sep09Oct10Nov11Dec12"
:0
* MONTHS ?? $ ^^.*($MONTH)\/[0-9][0-9]
{ MM = $MATCH }
DATESTAMP = "$YEAR$MM"
It's possible your "From " headers look different than mine, so some testing
of the above is necessary and you may need to localize it for your system.
:0:
* ^To:(_dot_)*port-alpha(_at_)NetBSD(_dot_)ORG
1) Add "X-List: port-alpha" field to the header.
2) Save it to the port-alpha.$DATESTAMP folder in my $MAILDIR.
3) Pipe a copy of the complete message to an external mailprocessing
program called "foo" on stdout.
I'll assume you have procmail 3.11pre4 or higher. If you don't, substitute
"^TO" for "^TO_" in the condition.
:0
* ^TO_port-alpha(_at_)NetBSD(_dot_)ORG
{
:0fhw
| formail -I"X-List: port-alpha"
:0c
| foo
:0:
port-alpha.$DATESTAMP
}
:0:
(Normal mail that should be delivered to my default inbox.)
1) Add "X-List: inbox" field to the header.
2) Save it to my $DEFAULT inbox.
3) Pipe a copy of the complete message to the external program.
At the very end of your .procmailrc:
:0fhw
| formail -I"X-List: inbox"
:0c
| foo