[Mimedefang] A small question
Ron Hall
thorn at cc.mcgill.ca
Thu Sep 4 23:10:24 EDT 2003
Perhaps I am missing something in the overall configuration
but below is my mimedefang-filter, very simple.
On one configuration is discard mail on
another does a reject with 4.7.1. No doubt I'm missing
something in the mix, but could someclue me in as to what
'zackly.
----- cut here ------
# -*- Perl -*-
#***********************************************************************
#
# mimedefang-filter
#
#***********************************************************************
#***********************************************************************
# Set administrator's e-mail address here. The administrator receives
# quarantine messages and is listed as the contact for site-wide
# MIMEDefang policy. A good example would be
'defang-admin at mydomain.com'
#***********************************************************************
$AdminAddress = 'postmaster at mcgill.ca';
$AdminName = "MIMEDefang Administrator's Full Name";
#***********************************************************************
# Set the e-mail address from which MIMEDefang quarantine warnings and
# user notifications appear to come. A good example would be
# 'mimedefang at mydomain.com'. Make sure to have an alias for this
# address if you want replies to it to work.
#***********************************************************************
$DaemonAddress = 'mimedefang at localhost';
#***********************************************************************
# If you set $AddWarningsInline to 1, then MIMEDefang tries *very*
hard
# to add warnings directly in the message body (text or html) rather
# than adding a separate "WARNING.TXT" MIME part. If the message
# has no text or html part, then a separate MIME part is still used.
#***********************************************************************
$AddWarningsInline = 0;
#***********************************************************************
# To enable syslogging of virus and spam activity, add the following
# to the filter:
# md_graphdefang_log_enable();
# You may optionally provide a syslogging facility by passing an
# argument such as: md_graphdefang_log_enable('local4'); If you do
this, be
# sure to setup the new syslog facility (probably in
/etc/syslog.conf).
# An optional second argument causes a line of output to be produced
# for each recipient (if it is 1), or only a single summary line
# for all recipients (if it is 0.) The default is 1.
# Comment this line out to disable logging.
#***********************************************************************
md_graphdefang_log_enable('mail', 1);
#***********************************************************************
# Uncomment this to block messages with more than 50 parts. This will
# *NOT* work unless you're using Roaring Penguin's patched version
# of MIME tools, version MIME-tools-5.411a-RP-Patched-02 or later.
#
# WARNING: DO NOT SET THIS VARIABLE unless you're using at least
# MIME-tools-5.411a-RP-Patched-02; otherwise, your filter will fail.
#***********************************************************************
# $MaxMIMEParts = 50;
#***********************************************************************
# Set various stupid things your mail client does below.
#***********************************************************************
# Set the next one if your mail client cannot handle nested multipart
# messages. DO NOT set this lightly; it will cause action_add_part to
# work rather strangely. Leave it at zero, even for MS Outlook,
unless
# you have serious problems.
$Stupidity{"flatten"} = 0;
# Set the next one if your mail client cannot handle multiple "inline"
# parts.
#***********************************************************************
# %PROCEDURE: filter
# %ARGUMENTS:
# entity -- a Mime::Entity object (see MIME-tools documentation for
details)
# fname -- the suggested filename, taken from the MIME
Content-Disposition:
# header. If no filename was suggested, then fname is ""
# ext -- the file extension (everything from the last period in the
name
# to the end of the name, including the period.)
# type -- the MIME type, taken from the Content-Type: header.
#
# NOTE: There are two likely and one unlikely place for a filename to
# appear in a MIME message: In Content-Disposition: filename, in
# Content-Type: name, and in Content-Description. If you are
paranoid,
# you will use the re_match and re_match_ext functions, which return
true
# if ANY of these possibilities match. re_match checks the whole
name;
# re_match_ext checks the extension. See the sample filter below for
usage.
# %RETURNS:
# Nothing
# %DESCRIPTION:
# This function is called once for each part of a MIME message.
# There are many action_*() routines which can decide the fate
# of each part; see the mimedefang-filter man page.
sub filter ($$$$)
{
my($entity, $fname, $ext, $type) = @_;
my $found = 0;
# return if message_rejected(); # Avoid unnecessary work
# Block virus warning message
if ($type =~ /^text/i)
{
if (defined $entity->bodyhandle)
{
if ( $io = $entity->bodyhandle->open("r"))
{
while (defined($_ = $io->getline))
{
if (/McGill NCS has removed the virus from your email/)
{
$found = 1;
last;
}
}
$io->close;
}
}
return action_discard() if $found == 1;
}
return action_accept();
}
# DO NOT delete the next line, or Perl will complain.
1;
HTH
As Always
r
More information about the MIMEDefang
mailing list