procmail
[Top] [All Lists]

Delete exe attachments and send email to sender/receiver

2001-06-26 08:32:07
Well here is what i have so far.  Bascialy it just sends the file to
/dev/null basicaly deleting the file. Now i want to add more functionality
to it. Here is what i have compiled so far:
#
#   Deletes attachments that are executable
#   And sends the sender and reciever emails explaining
#   that we dont accept executable files
#
:0 BD:
* Content-Disposition..attachment.
* filename=.*\.(exe|EXE).
{
        :0 c
        /dev/null

        :0 h
        | (formail -i"Subject: Executable file received" \
          -A"X-Filter: Executable attachment received and deleted" \
          -i"To:Postmaster(_at_)astcorp(_dot_)com"\
          -i"Content-type: text/plain; charset=\"us-ascii\""; \
          echo "Potential enclosed virus received."; \
          echo "Date: `/bin/date`"; \
          echo "The file has been sent to /dev/null and deleted";\
          ) | \
          $SENDMAIL -oi postmaster(_at_)astcorp(_dot_)com
}
#
Okay that is what i have and it appears to work for me.  I think by sending
it to /dev/null i am getting rid of all parts of the message and attachement
that way it doesnt take up space on the server.  Now the next step is to get
a email sent back to the sender stating this:

To the Sender:
We apologize but the AST email server does not allow employees to receive
executable (EXE) files through email transmissions.  Executable files often
contain viruses that have not been sent by the actual person but by a virus.
If you will "zip" the file up and resend your message then the intended
recipient will receive the message.

Again we apologize for the inconvenience.

Postmaster(_at_)astcorp(_dot_)com


Okay then now here is the letter being sent to the receiver of the email:

To the Recipient:
The email server has rejected a email sent to you from <Senders Email
Address>.  The message was rejected because it contained a executable (EXE)
file which could possible contain a virus.  In the future please have any
executables sent to you through a ZIP file or other means that will not
cause the email server to reject the file.

Thank you,
Postmaster(_at_)astcorp(_dot_)com

Okay now you get the jest of what im trying to do...so bascicaly im sure i
have to use this part of the current config:
       :0 h
        | (formail -i"Subject: Executable file received" \
          -A"X-Filter: Executable attachment received and deleted" \
          -i"To:Postmaster(_at_)astcorp(_dot_)com"\
          -i"Content-type: text/plain; charset=\"us-ascii\""; \
          echo "Potential enclosed virus received."; \
          echo "Date: `/bin/date`"; \
          echo "The file has been sent to /dev/null and deleted";\
          ) | \
          $SENDMAIL -oi postmaster(_at_)astcorp(_dot_)com

I just tweak those lines and add them in twice...once for the receiver and
once for the sender.  But how do i get the To field to be for the different
people?  I have only used procmail to send to a specific person and not a
constant changing variable like sending a email address of the receiver and
the sender.   Also i want in the message to the receiver to state the email
address at <Senders Email Address> where the problem came from, hrmm...would
be realy cool to put the email address and the persons name in the letter.
For example:   The email server has rejected a email sent to you from
<SendersName> coming from this email address:<Senders Email Address>.


Okay im done...probably to much info for such a simple task but i wanted to
make sure it was explained well enough :)

Thanks,
Tom Warfield
Systems Administrator
AST Corp
580-248-0321 ext 101
twarfield(_at_)astcorp(_dot_)com



_______________________________________________
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>
  • Delete exe attachments and send email to sender/receiver, Tom Warfield <=