The last thing to do when adding clamav and spamassassin to the mail server is to tell postfix to use them. What we are going to do is tell postfix to send any new mails it receives to amavisd, then, once amavisd has run the mail through mail and spam checks, to re-inject that mail into the mail queue.

It is very easy to tell postfix to use amavisd. We need to edit and Firstly we should edit In your favorite editor open up /etc/postfix/ Add the following 2 lines to the end of the file.

content_filter = amavis:[]:10024
strict_rfc821_envelopes = yes

This tells postfix that amavisd is listening on port 10024 for mails. It also tells postfix to make sure that the mails conform to rfc 821. Next we need to add to the file. Open up /etc/postfix/ in your favorite editor and add the following lines to the end of the file. inet n - n - - smtpd
  -o content_filter=
  -o local_recipient_maps=
  -o relay_recipient_maps=
  -o smtpd_helo_restrictions=
  -o smtpd_restriction_classes=
  -o smtpd_client_restrictions=permit_mynetworks,reject
  -o smtpd_sender_restrictions=
  -o smtpd_recipient_restrictions=permit_mynetworks,reject
  -o mynetworks=,,
  -o strict_rfc821_envelopes=yes
  -o smtpd_error_sleep_time=0
  -o smtpd_soft_error_limit=1001
  -o smtpd_helo_restrictions=
  -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
  -o smtpd_bind_address=

This tells postfix to listen on 10025 for mails from amavisd to be re-injected into the mail queue. But we need to also tell postfix to send mail that has arrived to amavisd for processing. We do that by adding the following code to the end of the file.

amavis unix - - n - 2 smtp
  -o smtp_data_done_timeout=1200
  -o smtp_never_send_ehlo=yes
  -o disable_dns_lookups=yes
  -o smtp_send_xforward_command=yes
  -o fallback_relay=localhost:10025

This tells postfix to send incoming mails through amavisd for content checks.

Now we should have amavisd using clamav and spamassassin performing virus and spam checks on all incoming mails. There are a great many options to amavisd and spamassassin. If you would like to extend your usage of these packages, please read the documentation that comes with the source files.