[Linux-Anyway] Re: Procmailrc thing

  • From: Meph Istopheles <Meph@xxxxxxxxxx>
  • To: Linux-Anyway@xxxxxxxxxxxxx
  • Date: Tue, 9 Nov 2004 15:13:45 -0800 (PST)

>>    Sorry I asked -- I didn't think it would anger you;-).

> Angered, moi!? :o)

   !!!!!!!!!!!!!!!;-)

>>    I'll look into writing up such a script.  Thanks.

> Check if you have formail installed on your box. It could 
> simplify things greatly - as in turn it into a 5-line bash 
> script, something like this:

   Whoo-hoo!  While I'm familiar with the name formal, I've never 
had occasion to even look at it.  It appears, from the man page, 
to be ~zackly~ what I'm looking for.

> #!/bin/bash
> cat > /tmp/acmescript$$
> NEWSUBJECT="[your tag here]`formail -xSubject < /tmp/acmescript$$`"
> cat /tmp/acmescript$$ | formail -I "Subject: $NEWSUBJECT"
> rm /tmp/acmescript$$

> Note the absence of a space between the closing bracket of your 
> tag and the opening backtick...

   OK.  Also, are the square brackets what I'd suggested, as with 
most lists, or are they only what you'd used?  I'd hate to put 
them in if, for some idiot reason, they're actually commands;-).

> What this does is basically as follows:

> cat > /tmp/acmescript$$
> Sucks up the mail being passed to it by procmail on stdin and 
> places this in a file under /tmp with a unique name (the 
> environment variable $$ is the PID of the running shell).

> NEWSUBJECT="[your tag here]`formail -xSubject < 
> /tmp/acmescript$$`" formail -xSubject < /tmp/acmescript$$ will 
> push the data through formail, which will look for the Subject: 
> header and output everything on the line after the colon, 
> including the space which separates the colon from the content. 
> This is tagged on to the end of [your tag here] and put in the 
> variable NEWSUBJECT.

> cat /tmp/acmescript$$ | formail -I "Subject: $NEWSUBJECT"
> The mail is pumped through formail once again, this time 
> replacing the "Subject:" header with your new subject, and the 
> result is pumped out through stdout and therefore picked up 
> again by procmail.

> rm /tmp/acmescript$$
> Just cleans up after the job was done.

   Curious:  While procmailrc will only send what I tell it to, in 
this case things from the pine mailing list (which, actually, 
will have to be in the To line, as the list is set to put the 
actual sender in the From line), everything I see in formail 
relates to the From.  Will there be any conflict as each would 
have a different person in the From line?

-- 
   Rule of Feline Frustration:
   When your cat has fallen asleep on your lap and looks utterly
   content and adorable, you will suddenly have to go to the
   bathroom.
To unsubcribe send e-mail with the word unsubscribe in the body to:   
Linux-Anyway-Request@xxxxxxxxxxxxx?body=unsubscribe

Other related posts: