EmailServer.AmavisdNew HistoryHide minor edits - Show changes to markup Friday 23 January 2009, at 07:19 GMT+8
by -
Added line 26:
$mydomain = 'example.com'; Changed lines 29-30 from:
If you are scanning mail for more than one domain, list them in here. to:
Replacing Thursday 22 January 2009, at 10:45 GMT+8
by -
Changed line 167 from:
< Dovecot | EmailServer | SpamAssassin > to:
< Dovecot | EmailServer | ClamAV Antivirus > Thursday 22 January 2009, at 10:38 GMT+8
by -
Changed lines 153-154 from:
OK, now we're ready to install the antispam and antivirus that will make use of Amavisd-New. to:
TestingFollow the simple testing procedures listed on the amavisd website to make sure that postfix and amavisd are properly configured: http://www.ijs.si/software/amavisd/README.postfix.html#basics_testing The only error you may be getting is related to hte lack of antivirus, something we'll move onto now. Thursday 22 January 2009, at 10:28 GMT+8
by -
Added line 112:
-o max_use=20 Thursday 22 January 2009, at 10:20 GMT+8
by -
Changed lines 95-96 from:
Edit your to:
Edit your Changed lines 98-99 from:
virusalert : postmaster spam.police : postmaster to:
virusalert : administrator spam.police : administrator Added line 158:
Thursday 22 January 2009, at 10:16 GMT+8
by -
Changed lines 97-98 from:
virusalert : administrator spam.police : administrator to:
virusalert : postmaster spam.police : postmaster Thursday 22 January 2009, at 09:40 GMT+8
by -
Deleted lines 12-64:
If you want or need to install it by hand, get the latest package and have a look at
We make sure that the user is unpriviledged and that its home directory is under Now install Amavisd-New by doing the following from the command line (check the latest version number of Amavisd-New and replace it, this is just an example): (:source lang=:)
(:sourcend:) To manage Amavisd-New like any other service, do the following: (:source lang=:)
(:sourcend:)
Now we can use Since Amavisd-New is written in Perl and is built aupon the work of many other individuals, we need to install some prerequisites: (:source lang=:)
(:sourcend:) (:noteblock:)
Easier CPAN installation
(:notecontent:)
One other option that I find useful is to enable Perl to just download what it needs instead of asking me every time: when asked Policy on building prerequisites (follow, ask or ignore)? type follow instead of the default ask. At the Perl shell prompt, type the long line of prerequisites for Amavisd-New:
(:source lang=:)
cpan> install Archive::Tar Archive::Zip Compress::Zlib Convert::TNEF Convert::UUlib MIME::Base64 MIME::Parser Mail::Internet Net::Server Net::SMTP Digest::MD5 IO::Stringy Time::HiRes Unix::Syslog BerkeleyDB
(:sourcend:)
You can of course break that into multiple Now we need to make sure that some other optional software needed by Amavisd-New is correclty installed on our machine (they are used to extract content in archived attachments): (:source lang=:)
(:sourcend:) Thursday 22 January 2009, at 09:39 GMT+8
by -
Changed line 8 from:
First thing to do is to add a user for running Amavisd-New: to:
It used to require some work to install Amavisd-New but it now has been included in most distributions, so installing it along with its numerous dependencies is as simple as: Changed lines 10-16 from:
to:
Added line 13:
If you want or need to install it by hand, get the latest package and have a look at Wednesday 13 July 2005, at 14:00 GMT+8
by -
Changed line 64 from:
Now we need to make sure that some other software needed by Amavisd-New is correclty installed on our machine: to:
Now we need to make sure that some other optional software needed by Amavisd-New is correclty installed on our machine (they are used to extract content in archived attachments): Added lines 66-69:
Wednesday 13 July 2005, at 13:12 GMT+8
by -
Changed lines 181-182 from:
to:
Note: if you reduced the number of Tuesday 12 July 2005, at 14:50 GMT+8
by -
Changed lines 207-208 from:
to:
Sunday 10 July 2005, at 18:02 GMT+8
by -
Changed lines 41-42 from:
Now we can use to:
Now we can use Sunday 10 July 2005, at 16:06 GMT+8
by -
Changed line 187 from:
White and Black liststo:
Amavisd-New White and Black listsSunday 10 July 2005, at 15:56 GMT+8
by -
Changed line 101 from:
$final_virus_destiny = D_DISCARD; to:
$final_virus_destiny = D_DISCARD; Changed line 111 from:
$final_banned_destiny = D_BOUNCE; to:
$final_banned_destiny = D_BOUNCE; Deleted line 118:
qr'.\.(exe|vbs|pif|scr|bat|cmd|com|cpl)$'i, # banned extension - basic Changed line 122 from:
wsc|wsf|wsh)$'ix, # banned ext - long to:
wsc|wsf|wsh)$'ix, Changed lines 132-133 from:
The most basic setup is to let the user deal with the spam. The good thing about that is that they can judge if there is a false positive, and can still separate the spam by using filters in their mail clients to automatically move marked spam to a local folder. to:
The most basic setup is to let the user deal with the spam. The good thing about that is that they can judge if there is a false positive, and can still separate the spam by using filters in their mail clients to automatically move marked spam to a local folder. Deleted lines 148-151:
When Amavisd-New finds a virus or spam, it notifies you by sending an email with a report. It's a good idea to have a separate user account to receive these so you can check if there is no false positives from time to time. Don't use your own mailbox for that or you'll be swamped with these messages (or at least use mail filtering in your client to automatically separate these). Changed line 184 from:
content_filter = smtp-amavis:127.0.0.0:10024 to:
content_filter = smtp-amavis:[127.0.0.0]:10024 Sunday 10 July 2005, at 15:33 GMT+8
by -
Added line 69:
Changed lines 77-80 from:
When Amavisd-New finds a virus or spam, it notifies you by sending an email with a report. It's a good idea to have a separate user account to receive these so you can check if there is no false positives from time to time. Don't use your own mailbox for that or you'll be swamped with these messages (or at least use mail filtering in your client to automatically separate these). Edit your to:
Here we tell Amavisd-New that it will be running under the Changed lines 80-81 from:
virusalert : administrator spam.police : administrator to:
@local_domains_maps = ( [".$mydomain", "example2.com", "example3.com"] ); Changed lines 82-107 from:
Again, don't forget to rebuild the aliases database with Configuring Postfix to use Amavisd-NewNow we need to let postfix know about Amavisd-New. Postfix communicates with external programs through TCP/IP ports. This method allows a clear separation of processes and their priviledges as each is running under its own account. Edit the -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes 127.0.0.1:10025 inet n - y - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -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 -o receive_override_options=no_header_body_checks to:
If you are scanning mail for more than one domain, list them in here. (:source lang=Perl:) $max_servers = 5; Changed lines 87-90 from:
And edit to:
This tells Amavisd-New to always fork 5 children waiting for our mails. This means that, at any time, we'll be able to process 5 emails simultaneously. If you don't have much RAM, you can lower this figure to (:source lang=Perl:) $sa_tag_level_deflt = undef; $sa_tag2_level_deflt = 6.31; Changed lines 93-208 from:
to:
Ensures that we always get X-Spam-Status and X-Spam-Level in our email headers, whatever the spam score, that anything above a spam score (see SpamAssassin) will be flagged as spam. (:source lang=Perl:) $sa_spam_subject_tag = '[SPAM] '; (:sourcend:) This is what will be shown in the subject of an email detected as spam. (:source lang=Perl:) $final_virus_destiny = D_DISCARD; (:sourcend:) We will quarantine messages containing viruses so they are not delivered to the user (when our antivirus will be installed). (:source lang=Perl:) @bypass_virus_checks_maps = (1); (:sourcend:) We also disable virus checking for now because we haven't installed the antivirus yet and Amavisd-New will not let mail through if this option is disabled and there is no Antivirus. (:source lang=Perl:) $final_banned_destiny = D_BOUNCE; $banned_filename_re = new_RE( qr'\.[^./]*[A-Za-z][^./]*\.(exe|vbs|pif|scr|bat|cmd|com|cpl|dll)\.?$'i,
qr'^application/x-msdownload$'i,
qr'^application/x-msdos-program$'i,
qr'^application/hta$'i,
[ qr'^\.(rpm|cpio|tar)$' => 0 ],
[ qr'^\.(zip|rar|arc|arj|zoo)$'=> 0 ],
qr'.\.(exe|vbs|pif|scr|bat|cmd|com|cpl)$'i, # banned extension - basic
qr'.\.(ade|adp|app|bas|bat|cmd|com|cpl|crt|exe|fxp|grp|hlp|hta|
inf|ins|isp|js|jse|lnk|mda|mde|mdw|mdt|mdz|msc|msp|mst|
ops|pcd|pif|prg|reg|scr|sct|shb|shs|vb|vbe|vbs|
wsc|wsf|wsh)$'ix, # banned ext - long
qr'.\.(mim|b64|bhx|hqx|xxe|uu|uue)$'i,
qr'^\.(exe-ms)$',
); (:sourcend:) Here we make sure that emails containing attachments with banned extensions get bounced. While we'll probably end up trying to bounce viruses and spam, it's better to use this option to let legitimate senders who are sending us banned attachements that their messages did not get through. We now have a couple of choices: sending our spam to the user with the modified subject line, or quarantine the message by sending it to a special user account. Basic setup: spam email sent to userThe most basic setup is to let the user deal with the spam. The good thing about that is that they can judge if there is a false positive, and can still separate the spam by using filters in their mail clients to automatically move marked spam to a local folder. In Advanced setup: quarantine to a special accountIf instead of cloggin the users with spam messages we want to move them to a special user account on the server, we need to modify the following in (:source lang=Perl:) $sa_kill_level_deflt = 6.31; $final_spam_destiny = D_DISCARD; (:sourcend:) When Amavisd-New finds a virus or spam, it notifies you by sending an email with a report. It's a good idea to have a separate user account to receive these so you can check if there is no false positives from time to time. Don't use your own mailbox for that or you'll be swamped with these messages (or at least use mail filtering in your client to automatically separate these). Edit your Configuring Postfix to use Amavisd-NewNow we need to let postfix know about Amavisd-New. Postfix communicates with external programs through TCP/IP ports. This method allows a clear separation of processes and their priviledges as each is running under its own account. Edit the -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes 127.0.0.1:10025 inet n - y - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -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 -o receive_override_options=no_header_body_checks (:sourcend:) And edit White and Black listsIf you want to make sure that some addresses always get through and that some always get banned, you will need to create a white list and a black list. (:source lang=:)
(:sourcend:) You need to make Amavisd-New know about those files. Edit Now simply add each email address you want to unconditionnaly allow (white list)/block (black list) on a single line inside the relevant file. Sunday 10 July 2005, at 11:55 GMT+8
by -
Changed lines 6-7 from:
Amavisd is a mail filtering interface that allows an MTA such as Postfix to talk to specialzed external add-ons such as SpamAssassin or ClamAV amongst others. to:
Amavisd is a mail filtering interface that allows an MTA such as Postfix to talk to specialzed external add-ons such as SpamAssassin or ClamAV amongst others. On its own, it doesn't do anything useful, but it will make our anstispam and antivirus tools work well together. Changed line 11 from:
to:
Added line 13:
Added lines 15-16:
Added line 28:
Added line 30:
Added line 70:
$max_servers = 5; Added line 74:
$MYHOME = '/var/amavis'; Changed line 91 from:
smtp-amavis unix - - y - 2 smtp to:
smtp-amavis unix - - y - 5 smtp Added line 117:
OK, now we're ready to install the antispam and antivirus that will make use of Amavisd-New. Sunday 10 July 2005, at 11:28 GMT+8
by -
Changed lines 5-7 from:
Amavisd-NewDo the following from the command line (check the latest version number of Amavisd-New and replace it, this is just an example): to:
Installing Amavisd-NewAmavisd is a mail filtering interface that allows an MTA such as Postfix to talk to specialzed external add-ons such as SpamAssassin or ClamAV amongst others. First thing to do is to add a user for running Amavisd-New: Added lines 10-19:
(:sourcend:) We make sure that the user is unpriviledged and that its home directory is under Now install Amavisd-New by doing the following from the command line (check the latest version number of Amavisd-New and replace it, this is just an example): (:source lang=:) Changed lines 28-29 from:
Since Amavisd-New is written in Perl and is built aupon the work of many other individuals, we need to install some prerequisites: to:
To manage Amavisd-New like any other service, do the following: Changed lines 30-34 from:
to:
Changed lines 36-43 from:
to:
Now we can use Since Amavisd-New is written in Perl and is built aupon the work of many other individuals, we need to install some prerequisites: (:source lang=:)
(:sourcend:) Added lines 52-109:
At the Perl shell prompt, type the long line of prerequisites for Amavisd-New:
(:source lang=:)
cpan> install Archive::Tar Archive::Zip Compress::Zlib Convert::TNEF Convert::UUlib MIME::Base64 MIME::Parser Mail::Internet Net::Server Net::SMTP Digest::MD5 IO::Stringy Time::HiRes Unix::Syslog BerkeleyDB
(:sourcend:)
You can of course break that into multiple Now we need to make sure that some other software needed by Amavisd-New is correclty installed on our machine: (:source lang=:) (:sourcend:) Configuring Amavisd-NewConfiguring Amavisd-New is simply a matter of editing its When Amavisd-New finds a virus or spam, it notifies you by sending an email with a report. It's a good idea to have a separate user account to receive these so you can check if there is no false positives from time to time. Don't use your own mailbox for that or you'll be swamped with these messages (or at least use mail filtering in your client to automatically separate these). Edit your Configuring Postfix to use Amavisd-NewNow we need to let postfix know about Amavisd-New. Postfix communicates with external programs through TCP/IP ports. This method allows a clear separation of processes and their priviledges as each is running under its own account. Edit the -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes 127.0.0.1:10025 inet n - y - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -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 -o receive_override_options=no_header_body_checks (:sourcend:) And edit Sunday 10 July 2005, at 10:05 GMT+8
by -
Changed lines 9-14 from:
cd /usr/local/src/ wget http://www.ijs.si/software/amavisd/amavisd-new-2.3.2.tar.gz tar xzvf amavisd-new-2.3.2.tar.gz cd amavisd-new-2.3.2 cp amavisd /usr/local/sbin/ cp amavisd.conf /etc/ to:
Added lines 16-30:
Since Amavisd-New is written in Perl and is built aupon the work of many other individuals, we need to install some prerequisites: (:source lang=:)
(:sourcend:) (:noteblock:)
Easier CPAN installation
(:notecontent:)
One other option that I find useful is to enable Perl to just download what it needs instead of asking me every time: when asked Policy on building prerequisites (follow, ask or ignore)? type follow instead of the default ask. Sunday 10 July 2005, at 06:45 GMT+8
by -
Added line 1:
![]() Sunday 10 July 2005, at 05:36 GMT+8
by -
Added lines 1-20:
This page is part of the EmailServer article. Amavisd-NewDo the following from the command line (check the latest version number of Amavisd-New and replace it, this is just an example): (:source lang=:) cd /usr/local/src/ wget http://www.ijs.si/software/amavisd/amavisd-new-2.3.2.tar.gz tar xzvf amavisd-new-2.3.2.tar.gz cd amavisd-new-2.3.2 cp amavisd /usr/local/sbin/ cp amavisd.conf /etc/ (:sourcend:) < Dovecot | EmailServer | SpamAssassin > (:comments:) |