procmail
[Top] [All Lists]

Re: Rewriting From: and Subject:

2000-09-19 08:49:58
Sean must have awakened too early after a sleepless night.  He advised
Florian,

| :0h
| * ^Subject:[    ]*\/.*
| SUBJECT=$MATCH

That would lose the body and save the head to a file named $MAILDIR/SUBJECT=
(since $MATCH will almost always begin with a space).

| :0h
| * ^From:[       ]*\/.*
| FROM=$MATCH

That would do the same to $MAILDIR/FROM= if it ever were executed.

When Sean has had his morning can of Jolt and is fully alert (is Jolt still
on the market?) -- he'll remember these:

1. You can't use an assignment as the action of a recipe (except a variable
   capture).  You use a left brace and put the assignment between the braces.

2. The `h' flag is meaningless when the action is (or should be) a left brace.

3. Regexp wildcards are stingy to the left of \/ (or in the absence of \/),
   greedy to the right of \/.  "[       ]*" will be matched to nothing that
   way, and any spaces or tabs to the immediate right of the colon will be
   included in $MATCH.

If Florian wants to go that route, they have to be written like this.  The
empty-looking brackets enclose space and tab, and those with carets between
them enclose caret, space, tab:

  :0
  * ^Subject:[  ]*\/[^  ].*
  { SUBJECT=$MATCH }

  :0
  * ^From:[     ]*\/[^  ].*
  { FROM=$MATCH }

Those do require that Subject: and From: each contain at least one non-blank
character.  We can handle other cases easily enough:

  :0
  * ^Subject:[  ]*\/[^  ].*
  { SUBJECT=$MATCH }
  :0E
  { SUBJECT="empty, blank, or missing" }

  :0
  * ^From:[     ]*\/[^  ].*
  { FROM=$MATCH }
  :0E
  { FROM=missing }


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>