procmail
[Top] [All Lists]

RE: autorespond recipe

2007-05-26 09:56:27
Chirag Ravishankar write in Wednesday, May 23, 2007 4:56 PM:

I would like to reply to a sender's message by my own message 
such as "Thank you for your mail, I will repond to it 
momentarily" AND I would like to send all the contents (body 
and attachments) back to the sender. So far, I am running the 
following autoreply script: 

:0 h c
* !^FROM_DAEMON
* !^X-Loop: mail@<mydomain> 
<mailto:mail(_at_)pc4(_dot_)apl(_dot_)utoronto(_dot_)ca> 
| (formail -r -A"Precedence: junk" \
-A"X-Loop: mail@<mydomain> 
<mailto:mail(_at_)pc4(_dot_)apl(_dot_)utoronto(_dot_)ca> 
" ; \ echo "Mail has been received and will be replied to 
shortly. Thank you for your patience.") | $SENDMAIL -t


It is sending that message back to the sender, but I want to 
subject of that message to be "autoreply" and the contents 
should be that message PLUS the contents of the sender's 
message. How do I do that? Please help.. 

I already wrote the other day that you probably want the -f
option to sendmail.  I worked some more on this whole approach
of quoting the body and adding a prefix, in text-only.  It
took me a bit of work to get it working.  Here it is.

Note that you need a LINEBUF setting big enough for the biggest
message you intend to quote, plus of course more "buffer" space
for normal ops on top of that.  I put such a setting in here
below.  On my system, while -f is honored for SENDMAIL, it only
works if the address is real.  Other systems may or may not
honor the -f flag.  Depends on the administrator and settings.

Oh: this will only *quote* MIME-encoding of attachments.
It will be very ugly.  Obviously, if you really want to
send the entire body back with attachments, you need to
do things a bit differently -- especially if the body is
not plaintext.  As I said earlier, you will have problems
injecting a message ("prepending") in a MIME body without
special tools beyond procmail and formail.

Dallman

########################### start replyrcfile ###########################

 NEWFROM = "mynewfrom(_at_)address"

 :0
#* {other conditions}
 * !^FROM_DAEMON
 * !^X-Loop:(.*\<)?$NEWFROM$
 {
   :0 fw
   | formail -rkp "> "                    \
             -A "Precedence: junk"        \
             -A "X-Loop: $NEWFROM"        \
             -i "Reply-To: $NEWFROM"      \
             -i "Return-Path: $NEWFROM"   \
             -i "Sender: $NEWFROM"        \
             -i "From: $NEWFROM"          \
             -i "Subject: Auto-Reply"
   
   LINEBUF = 131072              # default was 2048
   NL      = "
"  MESSAGE = "This is an automatic reply to your message$NL"
   MESSAGE = "${MESSAGE}and has not been read by a human.$NL"
   BODY    = `formail -I ''`


   :0 fw bi  # I believe the i-flag is crucial here for bigger messages
   | echo "${MESSAGE}${BODY}"

   :0
   | "$SENDMAIL" $SENDMAILFLAGS -f "$NEWFROM" to(_at_)address

############################ end replyrcfile ############################


____________________________________________________________
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

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