procmail
[Top] [All Lists]

Re: procmail filtering for specific attachments

2004-11-03 13:39:53
On Wed, 03 Nov 2004 08:51:27 -0800, Marc Feldesman 
<feldesmanm(_at_)gmail(_dot_)com> wrote:
to facilitate the filtering), and then determine whether the
attachment is in the correct format.  If the format is correct, the
student automatically receives an email receipt telling them that I
received their document in an apparently acceptable form.  If the
paper comes in as an incorrect format, the student gets an email
telling him/her that the paper needs to be resent in the proper
format.

This is not too hard in procmail, at least to kludge it.

What you need to do is first, check if a message has an attachment, or
could have an attachment.  You do this first because you can check the
Content-Type header without getting into the body of the email.

:0
* Content-type:(.*\<)?multipart
{

   # If it does carry an attachment,
   # check the body for the filename

   :0 h
   CLEANFROM=|formail -IReply-To: -rtzxTo:

   :0fw
   * 987654321^0 B ?? (file)?name[  ]*=.*\.doc
   * 987654321^0 B ?? (file)?name[  ]*=.*\.rtf(d)
   | (formail -rt  -A "X-Loop: bsmith.autoreply.domain.tld" \
     -I "From: myaddress"; cat "/path/to/reply/text" ; echo; ) \
     | sendmail -oi -t -f $CLEANFROM
}

the empty echo, btw, is critical.

(this is untested, but it should get you going)

-- 
 ::::::===   <http://2blog.kreme.com>  ===::::::
 :: Build a man a fire and he'll be warm for  :: 
 :: a night, but set a man on fire and he'll  ::
 :: be warm for the rest of his life.         ::

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