procmail
[Top] [All Lists]

Re: How to do a complicated auto-reply?

2002-04-17 11:05:15
At 18:18 2002-04-17 +0200, Ralph SOBEK did say:
        Question: is it possible to split up an auto-reply across
multiple recipes?  Is it possible to slowly build the auto-reply body
across multiple recipes?

Yes, either use the 'f'ilter flag, which would change the active message, or simply emit the body and header texts into variables as you go - either building them into one variable, or into separate ones which the final delivery recipe uses to concatenate into one message:

:0
* somecondition
{
        BODYVARIABLE="$BODYVARIABLE
additional text"
}

(insert newlines where you believe them to be necessary for your particular construct).

Similarly, if the extra text is pretty static, you could just set flags which are used in the final delivery to select which file(s) you're going to concatenate:

:0
* somecondition #1
{
        FILE1=explanation1.txt
}

:0
* somecondition #n
{
        FILEn=explanationn.txt
}

:0
* anyconditions
| ( formail otherstuff ; cat $FILE1 $FILE2 $FILE3 $FILEn ) | sendmail stuff

Note that if you've already extracted the necessary info for a reply (the reply-to address) previously, you don't inherently need to pipe anything to formail - you can emit the headers, a blank line, then the body.

sed can be a useful tool in this process.

| formail -rtA"X-Loop:      sobek(_at_)irit(_dot_)fr" \
            -I"Reply-To:    sobek(_at_)irit(_dot_)fr" \
            -I"Subject:     $rsubj" \
            -a"Message-ID:"

Dood, why so much whitespace WITHIN the headers?

I suppose that procmail RC files cannot have local variables.

Procmail is linear, not procedural, so variables do not have a scope to be scoped to (local vs. module vs. global).

Another possibility is to write everything to a temporary file, and
the do an auto-reply at the end.  This looks like the most plausible
solution.

Don't forget the possibility of using an external process such as a perl script (which could also be used to create your unique file using a system call).

Is it possible to get procmail's PID in order to create a unique temporary file idenifier?

An often overlooked variable is $$:

        PMPID=$$


procmail: [17613] Wed Apr 17 10:32:59 2002
.
.
procmail: Assigning "PMPID=17613"


[snip - wow, a 10 line .sig, with so many links to choose from]

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

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