This patch adds a new feature to amavis in order to
check company policies.
Based on this feature, I have developed a plugin that
allows to integrate amavis and spamassassin.
Also with this feature, it's easy to develop plugins
that allow to stop mails based on corporative policies,
Here I send two simple modules.
I would like that amavis developers include this work
in the official version.
The work is:
1.- I have removed some comments and added some code to
AMAVIS.pm in order to include policy checks.
2.- I submit 2 simple policy checks:
The first one allows to check the magic type of the
attachemts using File::LibMagic::
The second allows to deny emails with excesive size
or mails suspicious of mailing (waste a lot of bandwidth).
3.- I submit a policy check that allows to stop emails
You need to install AMAVIS::Policy::SpamAssassin perl
4.- I have written a notificator that allows to notify
the policies unsatisfied.
5.- Also I have done a little modification to
PMilter.pm, so policy tests can add custom headers to
the original email.
How to install:
1.- Download the AMAVIS.pm.diff and all the modules you
want to use from this site.
2.- Change into the directory where you have the amavis
sources unpacked: amavis-ng-0.1.6.9.
3.- patch the AMAVIS.pm file:
patch < /path_to_downloaded_files/AMAVIS.pm.diff
4.- (Opcionally) if you are using sendmail + PMilter
MTA, patch the PMilter.pm:
patch < /path_to_downloaded_files/PMilter.pm.diff
5.- Create the AMAVIS/Policy directory and copy here
the policy modules
6.- Copy the PolicyNotificator.pm into AMAVIS/Notify
7.- perl Makefile.PL
8.- make install
Sample of configuration (amavis.conf)
policy = MailSize
policy = AttachType
policy = SpamAssassin
notifiers = PolicyNotificator, Recipients, Admin
; max message size
filesize = 10000000
; max mailing size (mailsize * number_of_recipients)
mailingsize = 100000000
notify to = sender, recipient, admin
description = Excesive size for the email
; The syntax is recipient_regexp:magicfile_regexp (use
file command to know magic string).
extensions = .*:^PE executable, yahoo.com:^MPEG
notify to = recipient, admin
description = Attachment not allowed
; You must to create manually the dir
user_dir = /var/spool/spamassassin
userstate_dir = /var/spool/spamassassin
userprefs_path = /var/spool/spamassassin/user_prefs
notify to =
description = We do not allow spam emails