FreeBSD13.3 ; Postfix ClamAV + Amavis + SpamassAssin

Install ClamAV on FreeBSD 13 and link it with Amavis against Postfix.
ClamAV is anti-virus software.
We will proceed on the assumption that you have already implemented Postfix.
Before proceeding, update the Ports Collection.

1. ClamAV

1.1 Install

Each option is installed by default for now


1.2 Configuration File Editing

①Edit clamd.conf
Run ClamAV as root user

➁Edit freshclam.conf
Settings about virus pattern files

1.3 Virus database update

1.4 ClamAV start

ClamAV auto-start configuration


1.5 manual virus check

To manually check for viruses, do the following

To create a test virus file and check for viruses

/usr/home/virustest.txt: Eicar-Signature FOUND
/usr/home/virustest.txt: Removed.
The virus file has been found and deleted.

1.6 automatic virus scanning

• Scanning range is /home/.
• Output scan results to /var/log/clamav.log
• Automatic deletion of detected viruses
• Executed daily
Create an execution script with the above conditions

①Creation of virus storage directory

➁Shell Script Creation

Grant execution permissions to scripts

Register in cron to be executed at 0:00 AM

Run the following as a test

If you look at /var/log/clamav/clamav.log, you will see the same log as above

2. Amavis

Install Amavis, which links ClamAV and Postfix

2.1 Install

The option settings are as follows
SPAMASSASIN should be included.
IPv6 is not required, so remove the item.
Otherwise, proceed with defaults.

Proceed by default even on the option selection screen in the middle of the process.

2.2 Configuration File Editing

Edit amavisd.conf

2.3 Amavis Auto-Startup Configuration

Amavis start

2.4 Postfix Configuration



3. Anti-Spam with SpamAssassin

3.1 SpamAssassin Install

If you did not select spamassassin as an option when you installed Amavis, install it as follows

3.2 Configuration File Editing

3.3 Spamassassin start

3.4 SpamassAssin Update

Create an update script

Grant execution rights to scripts

When the script is executed, a local.cff is created for the date and time of execution

3.5 postfix restart

3.6 Spam mailbox creation

When using IMAP in this case

①Create spam mailboxes for existing users
Let's assume the existing user is huong

➁Create spam mailboxes for additional users

3.7 Edit procmailrc (for IMAP)

3.8 Spam Mail Learning

Create spam email learning scripts

3.9 Spam Mail Sending Test

Fill in the following in the body of the message in Thunderbird and send it to yourself.

The following message appears in the header of an incoming e-mail

X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on Lepard
X-Spam-Flag: YES
X-Spam-Level: ********************************************
X-Spam-Status: Yes, score=1001.8 required=13.0 tests=ALL_TRUSTED,
MULTIPART_ALTERNATIVE autolearn=no autolearn_force=no version=4.0.1
* 0.1 ALL_TRUSTED Passed through trusted hosts only via SMTP
* -0.1 CONTENT_TYPE_PRESENT exists:Content-Type
* 0.1 MULTIPART_ALTERNATIVE Multipart/alternative
* 1000 GTUBE BODY: Generic Test for Unsolicited Bulk Email
* 1.0 HTML_MESSAGE BODY: HTML included in message
* 0.7 MPART_ALT_DIFF BODY: HTML and text parts are different

Copied title and URL