List:
I am building a set of rules that use formail and procmail to return email
with certain attachments, such as exe, com and the like. This seems pretty
common and much of what I have was gotten from various web sites. What I
have is at the end of the email incase anyone is interested.
What I want is a way to extract the email body without the attachment so I
can included it in the reply. I know I can use "sed -e '1,/^$/ d'", but I
only want the text between the "Content-Type: text/plain" statement and the
next "Content-Type" statement. Anything after the second Content statement
will be the attachment that I do not want. Has anyone done this? I will
hack up something if it is not already there, but I am certain that it is.
My current rc follows, without the body stuff as I have not figured it out yet:
# Get the message subject
SUBJECT=`formail -xSubject: \
| sed -e 's/[;\`\\]/ /g' \
| expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
# Get the message To:
ORIGTO=`formail -xTo: \
| sed -e 's/[;\`\\]/ /g' \
| expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
# Next two return attachments that are identified as Content Type
:0BH
*
^Content-(Type|Disposition):.*name=.*\.\/(avi|mp3|wav|lnk|bat|pif|exe|com|zip|vbs|shs|hta|scr|chm)
*! ^From(_dot_)*james(_at_)mydomain(_dot_)org
*! ^X-Loop: no-reply(_at_)protecteddomain(_dot_)com
{
LOG='AUTOREPLIED ATTACHMENT: '
:0
|(formail -r -A "Precedence: junk" \
-I "From: AutoReply <no-reply(_at_)protecteddomain(_dot_)com>" \
-I "Subject: Rejected Attachment (Re: $SUBJECT sent to $ORIGTO)" \
-I "X-VIRUSWARNING: This file had a $MATCH attachment" \
-A "X-Loop: no-reply(_at_)protecteddomain(_dot_)com"; \
cat /etc/attachment.txt )| /usr/sbin/sendmail -t
:0
/dev/null
}
:0BH
* ^Content-Type.*(application)
* name=".*\/(mp3|wav|lnk|bat|pif|exe|com|zip|vbs|shs|hta|scr|chm|avi)"
*! ^From(_dot_)*james(_at_)mydomain(_dot_)org
*! ^X-Loop: no-reply(_at_)protecteddomain(_dot_)com
{
LOG='AUTOREPLIED ATTACHMENT: '
:0
|(formail -r -A "Precedence: junk" \
-I "From: AutoReply <no-reply(_at_)protecteddomain(_dot_)com>" \
-I "Subject: Rejected Attachment (Re: $SUBJECT sent to $ORIGTO)" \
-I "X-VIRUSWARNING: This file had a $MATCH attachment" \
-A "X-Loop: no-reply(_at_)protecteddomain(_dot_)com"; \
cat /etc/attachment.txt )| /usr/sbin/sendmail -t
:0
/dev/null
}
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail