procmail
[Top] [All Lists]

Re: Adding a subject line

2002-03-09 20:06:55
Chuck wrote,

| I tried this suggestion about a month ago, and it didn't work.
| Today I dusted it off and tried a couple of dozen permutations on
| this technique, and nothing has worked.  Are there any
| suggestions on what I might be missing?  I have verified that
| procmail is working for me on this system, and formail is on my
| path.

I don't remember your earlier post about it, but if you want to add a header
field only if it isn't already there,

 formail -a "Subject: Baker"

as in

 :0hfw
 | formail -a "Subject: Baker"

is the way to do it.  Yes, it's a good idea to run it only on messages that
need it and not fork formail for nothing if there already is a subject, such
as

 :0hfw
 * ! ^Subject:
 | formail -a "Subject: Baker"

Now, if by "no subject" you are including messages that have empty subject
headers or subject headers with only whitespace as contents, that's slightly
different:

 :0hfw # brackets enclose caret, space, tab
 * ! ^Subject:.*[^     ]
 | formail -i "Subject: Baker"

where we use -i instead of -a because (1) -a will do nothing if a field by
that name is already present, even if it has null or blank content and
(2) -I will kill any original one, while -i will rename it Old-Subject: so
that you can see what had been there beforehand.



_______________________________________________
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>