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.

Close

#33 Amavis + spamassassin integration

open
None
5
2007-02-11
2006-07-18
Manuel Carrasco
No

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:
AMAVIS/Policy/AttachType.pm
AMAVIS/Policy/MailSize.pm
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:
AMAVIS/Policy/SpamAssassin.pm
You need to install AMAVIS::Policy::SpamAssassin perl
module.
4.- I have written a notificator that allows to notify
the policies unsatisfied.
AMAVIS/Notify/PolicyNotificator.pm
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)

[global]
policy = MailSize
policy = AttachType
policy = SpamAssassin
notifiers = PolicyNotificator, Recipients, Admin

[MailSize]
; 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

[AttachType]
; 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

[SpamAssassin]
; 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

Discussion

  • Attachment policy checks

     
    Attachments
  • Mailing policy checks

     
    Attachments
  • Policy checks notifications

     
    Attachments
  • Logged In: YES
    user_id=1194907

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

     
  • Spam policy checks using spamassasin

     
    Attachments
  • Lars Hecking
    Lars Hecking
    2007-02-11

    • assigned_to: nobody --> braeucup