Ubuntu 10.04
Sponsored Link

Run with Clamav2010/07/25

[1] Configure SMTP Server in order to scan emails to protect from virus or spams. Install clamav first.
root@mail05:~#
aptitude -y install clamav-daemon amavisd-new spamassassin


root@mail05:~#
vi /etc/default/spamassassin


# line 8: change to "1" if you use spam filter

ENABLED=
1


root@mail05:~#
cp /usr/share/doc/amavisd-new/examples/amavisd.conf-sample.gz /etc/amavis/

root@mail05:~#
gunzip /etc/amavis/amavisd.conf-sample.gz

root@mail05:~#
mv /etc/amavis/amavisd.conf-sample /etc/amavis/amavisd.conf

root@mail05:~#
vi /etc/amavis/amavisd.conf


# line 66: uncomment

$MYHOME = '/var/lib/amavis';

# line 71: specify domain name

$mydomain = '
srv.world
';

# line 73: specify hostname

$myhostname = '
mail05.srv.world
';

# line 77,78: change

$daemon_user = '
amavis
';
$daemon_group = '
amavis
';

# line 626: make it comment ( not notify via email if virus detected )

#
$virus_admin
= "virusalert\@$mydomain";


root@mail05:~#
vi /etc/amavis/conf.d/15-content_filter_mode


# line 13: uncomment

@bypass_virus_checks_maps = (
  \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re);

# line 24: uncomment ( if you use spam filter too )

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

root@mail05:~#
vi /etc/postfix/main.cf


# add at the bottom

content_filter=smtp-amavis:[127.0.0.1]:10024


root@mail05:~#
vi /etc/postfix/master.cf


# add at the bottom

smtp-amavis unix -       -       n      -     2 smtp
      -o smtp_data_done_timeout=1200
      -o smtp_send_xforward_command=yes
      -o disable_dns_lookups=yes
127.0.0.1:10025 inet n     -     n     -     - smtpd
      -o content_filter=
      -o local_recipient_maps=
      -o relay_recipient_maps=
      -o smtpd_restriction_classes=
      -o smtpd_client_restrictions=
      -o smtpd_helo_restrictions=
      -o smtpd_sender_restrictions=
      -o smtpd_recipient_restrictions=permit_mynetworks,reject
      -o mynetworks=127.0.0.0/8
      -o strict_rfc821_envelopes=yes
      -o smtpd_error_sleep_time=0
      -o smtpd_soft_error_limit=1001
      -o smtpd_hard_error_limit=1000


root@mail05:~#
touch /etc/mailname

root@mail05:~#
chmod -R 775 /var/lib/amavis/tmp

root@mail05:~#
usermod -G amavis clamav

root@mail05:~#
/etc/init.d/clamav-daemon restart

 * Stopping ClamAV daemon clamd
  ...done.
 * Starting ClamAV daemon clamd
  ...done.
root@mail05:~#
/etc/init.d/spamassassin start

Restarting SpamAssassin Mail Filter Daemon: spamd.
root@mail05:~#
/etc/init.d/postfix restart

 * Stopping Postfix Mail Transport Agent postfix
  ...done.
 * Starting Postfix Mail Transport Agent postfix
  ...done.
root@mail05:~#
/etc/init.d/amavis restart

Stopping amavisd: amavisd-new.
Starting amavisd: amavisd-new.
root@mail05:~#
sysv-rc-conf clamav-daemon on

root@mail05:~#
sysv-rc-conf spamassassin on

root@mail05:~#
sysv-rc-conf amavis on

  These lines below are added in header section of emails after this configuration.
 
Matched Content