Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#33 Amavis + spamassassin integration

Manuel Carrasco

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 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
using spamassassin:
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, so policy tests can add custom headers to
the original email.

How to install:

1.- Download the 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-
3.- patch the file:
patch < /path_to_downloaded_files/
4.- (Opcionally) if you are using sendmail + PMilter
MTA, patch the
patch < /path_to_downloaded_files/
5.- Create the AMAVIS/Policy directory and copy here
the policy modules
6.- Copy the 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,^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


  • Attachment policy checks

  • Mailing policy checks

  • Policy checks notifications

  • Logged In: YES

    I'm sorry, I have a misprint, to use you
    must to install the Mail::SpamAssassin perl module.

  • Spam policy checks using spamassasin

  • Lars Hecking
    Lars Hecking

    • assigned_to: nobody --> braeucup