procmail
[Top] [All Lists]

Re: Help with recipesy

1997-01-14 22:14:42
Charles Gagnon seems to have said:
Hi list,
I've been using procmail for quite a while now and I love. I want to try
something a bit different now and I couldn't fine the info I needed 
in the man pages.

I want to be able to forward all messages sent to a specific 
account to another one (exemple, forward from user1 to user2 account). 
It gets a bit more complicated cause I'd like to add a comment in 
the body of the message mentionning the mail as been forwarded.

Exemple of a mail in User2 account:

 From: Someone(_at_)someplace(_dot_)in(_dot_)somecountry
 To: User1(_at_)Grafnetix(_dot_)COM
 Subject: Hello

 * NOTE: This mail as been automatically forwarded to you
 *       from User1(_at_)Grafnetix account

 Hello User1,
 How are you today...
I'd like procmail to add the note part before forwarding the massage to User2.
Is it possible and if yes, how?

TIA

I'm not a suscriber to this list yet so if you can, please reply to my address
directly, I'll summarize.

        I use a simple awk script like so:


#! /usr/bin/gawk -f
        ## insert a message between the header and
        ## the body of a message -- suitable for use
        ## with formail/procmail:

/^[ \t]*$/ && ! pastheader { 
        pastheader = 1 
        print "\n\n"
        system( "/bin/cat " file ) 
        print "\n\n" }

{ print }

        This searches for the first blank line (or line
        containing only whitespace) and
        inserts a copy of file at that point.

        The value of 'file' is set on the command line
        like so:

        :0c
        | ( formail -rk -A "$MYXLOOP" | \
            insert file=$HOME/doc/body.header ; \
            /bin/cat $HOME/doc/body.trailer ) | $SENDMAIL -t -oi

        I'm sure that similarly trivial scripts can be written
        in perl and directly in ksh/bash.  This might not 
        be a bad idea as a binary, coded in C -- if you have a 
        really busy mailbox.  It would even be cooler as a 
        option directly to formail!  formail doesn't take a 
        simple filename -- if one was provided we could default
        to just inserting or appending the contents of that file
        to the body of the message -- or we could just include
        another switch.  [looking through the man page a bit]

        We could use -w (for "with" appended) and -W (for "with"
        inserted) -- such that you'd use a command like:

                formail -rk -W /path/file.to.insert -w /path/sigfile

        ... would format a header and body -- as a reply, keeping
        the body from standard input, inserting the first file
        before the body and appending a signature file after
        the body.

        Wouldn't that make alot of reply recipes easier?
        Couldn't you imaging some cool ":0f " recipes that
        would be quicker and easier this way?

        Where do I "officially" send this as an enhancement
        request?  Anyone want to volunteer to write the code
        and submit the diffs (or do you want to trust my
        meager coding skills at it)?

-- 
Jim Dennis,                                
info(_at_)mail(_dot_)starshine(_dot_)org
Proprietor,                          
consulting(_at_)mail(_dot_)starshine(_dot_)org
Starshine Technical Services              http://www.starshine.org

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