procmail
[Top] [All Lists]

RE: autorespond recipe

2007-05-26 17:04:18
I wrote Saturday, May 26, 2007 8:43 PM:

Bart Schaefer wrote on Saturday, May 26, 2007 7:52 PM:

On 5/26/07, Dallman Ross <dman(_at_)nomotek(_dot_)com> wrote:

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.

http://www.well.com/user/barts/email/mimewrap.txt

Handles automatically increasing LINEBUF and turns the entire
original message into a message/rfc822 attachment.

Interesting.  I was just thinking one could simply
rewrite the headers and introduce a blank line and the
message text; then, when the header and body were
reattached, the stuff after the blank line would become
the top of the body.  I was thinking one could write
a MIME header similarly to what you did.

I have now done this.  It works.  No padding to LINEBUF
is needed.  We don't need to save the body to a var.

The below works on multipart/alternative, multipart/mixed,
and text/plain.  It won't work at present on
text/html, though.  (It could be further tweaked to do
so.)

The -b switch for formail -r avoids quoting the body,
which is what we want here.

The trick is that formail will happily inject newlines
into headers if so instructed.  So we create a new top
of body by adding a new *header*.  I chose X-Loop
because it will be used, and retained, anyway once
we invoke formail -r later.  But any dummy header would
do, since formail -r will delete most of the headers
anyway.

Bart, yours is excellent for including the current message
as an attachment.  This new approach here allows actual
editing of MIME parts by adding a new part and making
it all multipart/mixed.

Dallman


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

  NL = "
" DQ = '"'
  NEWFROM = mynewfrom(_at_)address

 :0
#* {other conditions}
 * !^FROM_DAEMON
 * !^X-Loop:(.*\<)?$NEWFROM$
 {

   MESSAGE = "${NL}${NL}This is an automatic reply to your message"
   MESSAGE = "${MESSAGE}${NL}and has not been read by a human."


   PSEUDOHEADERS  # initialize unset
   :0
   * $ ^Content-Type:.*boundary=$DQ\/[^$DQ]+
   {
      :0 h fw
      | formail -i "Content-Type: multipart/mixed; boundary=$DQ$MATCH$DQ"

      PSEUDOHEADERS =            "$NL$NL--$MATCH$NL"
      PSEUDOHEADERS = "${PSEUDOHEADERS}Content-Type: text/plain; "
      PSEUDOHEADERS = "${PSEUDOHEADERS}charset=${DQ}US-ASCII${DQ}$NL"
      PSEUDOHEADERS = "${PSEUDOHEADERS}Content-Transfer-Encoding: 7bit"
   }

   :0 fw h
   | formail -A "X-Loop: $NEWFROM$PSEUDOHEADERS$MESSAGE"


   :0 fw
   | formail -rkb -i "Content-Type:"    \
             -A "Precedence: junk"      \
             -i "Reply-To: $NEWFROM"    \
             -i "Return-Path: $NEWFROM" \
             -i "Sender: $NEWFROM"      \
             -i "From: $NEWFROM"        \
             -i "Subject: Auto-Reply"

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