procmail
[Top] [All Lists]

Re: Alter Body Based on Looked-up Data

2007-05-31 06:25:09
On Thu, May 31, 2007 at 07:58:36AM -0500, Sokol, Ryan - 244 wrote:

[Dallman Ross wrote:]

Is there some reason you have to send back the exact same
format you got?  As I mentioned previously, a tool such as
demime will work fine.

I have set up an auto-responder that I will leave up for
a couple of days, anyway.  Write "dman+procmail(_at_)nomotek(_dot_)com"
with any message style you want and you will get it back
demimed and quoted, with a message prepended.

Here is my code:

######################## start ########################

 TESTADDR = dman+procmail(_at_)nomotek(_dot_)com

 :0
 * $  ^To:(.*\<)$\TESTADDR
 * $ !^X-Loop:(.*\<)?$\TESTADDR
 {
    TESTMSG = "This is a canned message prepended to the body,${NL}"
    TESTMSG = "${TESTMSG}which has been demimed and will be delivered${NL}"
    TESTMSG = "${NL}${NL}${TESTMSG}back to ${RET_ADDR}."

    :0 fw
    | demime --uselynx

By the way, we don't need demime of the original was text.  I'd
put in a condition to skip this step in that case.  New recipe
for this part:

    :0 fw
    * ! ^Content-Type:.*text/plain
    | demime --uselynx

    :0
    | formail -rkp "> " -I "X-Loop: ${TESTADDR}${TESTMSG}" \
    | "$SENDMAIL" $SENDMAILFLAGS -t
 }


And for inclusion of but no quoting of the original body, use

    | formail -rkb -I "X-Loop: ${TESTADDR}${TESTMSG}" \

######################### end #########################

Note that a couple of things were predefined, such as NL
and RET_ADDR.  (I had that available already from my
regular .procmailrc, which the message has run through
by the time it gets here.)

[Sokol, Ryan - 244] 
Thanks for the help and code.  I tried your auto responder and it worked
just fine.  After all these possibilities, I think I'll take the
approach of creating my own attachment with the database looked up
information and add it onto the original email (kind of the SpamAssassin
approach).  That way the look and feel of the original email is
preserved and replies to the original will not contain the looked up
information.

That's fine.  As noted, Bart suggested that two days ago, and now LuKreme
piled on there too.  It's a good approach.

Thanks guys for your help.  Sorry for not posting correctly.  I'm new to
posting to mailing lists.  I usually just read them.

Learning's okay.  You're making an effort.  I will point out two more
list "netiquette" notions.  I don't mean to be patronizing in any way,
just informative.  The first is, please make sure you attribute quoted
text.  I added an attribution to my quoted words above.  The archives
are kept in perpetuity, and it's both good form and helpful to know
who was responsible for the words.

Second point is to be sure to trim out unnecessary things.  Quote
parts that are relevant to what you are responding to, but not other
text from the prior article.  I would have cut my entire sample code
here, for example, except that I decided to offer an improvement,
so left it in.  Certainly cut .sigs and such.  Thanks for being
willing to take suggestions without acquiring a chip on the shoulder. :-)

Dallman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail