Postfix: Installation et prise en main de Amavis couplé avec SpamAssassin

  • Installer amavis:

apt-get install amavisd-new

  • Installer spamassassin:

apt-get install spamassassin

  • Activer spamassassin:

modifier le fichier /etc/default/spamassassin

# Change to one to enable spamd
ENABLED=1

  • Modifier le fichier /etc/postfix/main.cf

Ajouter à la fin:

content_filter=amavis:[127.0.0.1]:10024

  • Modifier le fichier /etc/postfix/master.cf

Ajouter:

amavis unix - - n - 2 smtp
  -o smtp_data_done_timeout=1200
  -o smtp_send_xforward_command=yes

127.0.0.1:10025 inet n - n - - smtpd
  -o content_filter=
  -o smtpd_delay_reject=no
  -o smtpd_client_restrictions=permit_mynetworks,reject
  -o smtpd_helo_restrictions=
  -o smtpd_sender_restrictions=
  -o smtpd_recipient_restrictions=permit_mynetworks,reject
  -o smtpd_data_restrictions=reject_unauth_pipelining
  -o smtpd_end_of_data_restrictions=
  -o smtpd_restriction_classes=
  -o mynetworks=127.0.0.0/8
  -o smtpd_error_sleep_time=0
  -o smtpd_soft_error_limit=1001
  -o smtpd_hard_error_limit=1000
  -o smtpd_client_connection_count_limit=0
  -o smtpd_client_connection_rate_limit=0
  -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters
  -o local_header_rewrite_clients=
  -o smtpd_milters=
  -o local_recipient_maps=
  -o relay_recipient_maps=

  • Modifier le fichier /etc/amavis/conf.d/15-content_filter_mode

dé-commenter la ligne:

@bypass_spam_checks_maps = (
\%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re);

  • Modifier le fichier /etc/amavis/conf.d/05-domain_id, ajouter la liste des domaines gérés sur votre serveur:

modifier la ligne @local_domains_acl = ( “.$mydomain” ); par:

@local_domains_acl = ( '.' );

  • Modifier le fichier /etc/amavis/conf.d/20-debian_defaults

Ajouter:

$QUARANTINEDIR = "/home/spamassassin";
$sa_spam_subject_tag = '[SPAM]';
$sa_tag_level_deflt = undef; # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 4.8; # add ‘spam detected’ headers at that level

  • Créer le dossier des spams:

mkdir /home/spamassassin

chown amavis:amavis /home/spamassassin

  • Redémarrer les services:

service postfix restart

service amavis restart

service spamassassin restart

  • Pour tester envoyer un mail avec le sujet (GTUBE: the Generic Test for Unsolicited Bulk Email):
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

 

 
Résultat:
X-Quarantine-ID: <zr-2Ryn8Cy2l>
X-Spam-Flag: YES
X-Spam-Score: 999.912
X-Spam-Level: ****************************************************************
X-Spam-Status: Yes, score=999.912 tag=x tag2=4.8 kill=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
FREEMAIL_FROM=0.001, GTUBE=1000, HTML_MESSAGE=0.001,
RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, TVD_SPACE_RATIO=0.001,
T_TO_NO_BRKTS_FREEMAIL=0.01] autolearn=no