[SGVLUG] Who /really/ knows procmaIl around here?

John E. Kreznar jek at ininx.com
Mon Jul 3 11:41:24 PDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tom Emerson <osnut at pacbell.net> writes:

> I've got procmail set up to separate "discussion list" messages as follows:

>    :0
>    * ^List-id:.*<some.list.id>
>    .Discussion\ Groups.listname/

>    :0
>    * ^List-id:.*<another.list>
>    .Discussion\ Groups.othername/

>    :0
>    * ^List-id:
>    .Discussion\ Groups/

> The last is a "catch all" that puts any message that comes from a list
> into the top-level directory of my e-mail folders dedicated to list
> management.  Whenever I join a new list, I essentially have to edit this
> file to set a specific target other than "Discussion Groups".

> What I'm wondering is, is there a way to have the procmail script look
> for the actual ID and use that as the target?  Something along the lines
> of this:

>    :0
>    * ^List-id:.*[look for text in "<...>"; extract up to first "." char]
>    .Discussion\ Groups.[extracted item]

> this would be my new "catch all" rule, so when I join a new list, I
> don't specifically have to edit procmail unless I want to put this
> somewhere else (such as this list -- I have it a couple levels down from
> "discussion groups")

:0 hW
LISTIDLINE=|grep -m 1 -i '^list-id:'

:0 aw
.Discussion\ Groups.$(echo $LISTIDLINE | sed 's/^[^ ]* *\([^\.]*\)/\1/')

The "grep" line captures the first header ^List-id: line and the "sed"
line uses it to form the target name.

This is adapted from a working procrc but is NOT TESTED.

When you join a new group, you will still have to first make the
target directory.  In a refinement(?) of the above, the new directory
would be created if it does not already exist.

In my working reference for this, the $LISTIDLINE is actually passed
as a parameter to an external script which takes the mail itself on
stdin:

:0 aw
| scriptname $LISTIDLINE

This way, "scriptname" can do complicated things outside the limits
imposed by procmail.

- -- 
 John E. Kreznar jek at ininx.com 9F1148454619A5F08550 705961A47CC541AFEF13
  Imagine there's no countries / to kill or die for  --John Lennon, 1971

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>

iD8DBQFEqWTRYaR8xUGv7xMRAouWAJsEPYBcB02EQdRWuK3UrD8xI7BlSgCfQNAq
MLTblf2W3zuRFa3TQte+A5Q=
=g00M
-----END PGP SIGNATURE-----



More information about the SGVLUG mailing list