FreeBSD14.2 ; Postfix ClamAV + Amavis + SpamassAssin

Install ClamAV on FreeBSD 14.2 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

clamav version check

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

start

1.5 manual virus check

To manually check for viruses, do the following(Scanning range is /home/)

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.

2.2 Configuration File Editing

Edit amavisd.conf

2.3 Amavis Auto-Startup Configuration

Amavis start

2.4 Postfix Configuration

①Edit main.cf

➁Edit master.cf

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

When I send a blank email to myself in Thunderbird, the following message appears in the header of the received email

X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: xxxxx@korodes.com
X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on Lepard
X-Spam-Level: **
X-Spam-Status: No, score=2.3 required=13.0 tests=ALL_TRUSTED,

CONTENT_TYPE_PRESENT,EMPTY_MESSAGE autolearn=no autolearn_force=no
version=4.0.1
X-Original-To: xxxxx@korodes.com
Delivered-To: xxxxx@korodes.com
Received: from lepard (localhost [127.0.0.1])
by mail.korodes.com (Postfix) with ESMTP id 6DC012925C
for xxxxx@korodes.com; Sun, 08 Dec 2024 11:12:47 +0900 (JST)
X-Virus-Scanned: amavisd-new at korodes.com
Received: from mail.korodes.com ([127.0.0.1])
by lepard (mail.korodes.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
id 1bDaORJjFXRY for huong@korodes.com;
Sun, 8 Dec 2024 11:12:47 +0900 (JST)
Received: from [192.168.11.45] (buffalo.setup [192.168.11.1])
by mail.korodes.com (Postfix) with ESMTPSA id 513342928D
for xxxxx@korodes.com; Sun, 08 Dec 2024 11:12:47 +0900 (JST)
Message-ID: fc19537b-dd11-427c-b2a4-4f58035fb755@korodes.com
Date: Sun, 8 Dec 2024 11:12:46 +0900
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: huong xxxxx@korodes.com
Content-Language: en-US
To: xxxxx@korodes.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Subject:

Fill in the following in the body of the message in Thunderbird and send it to yourself.
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

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,
CONTENT_TYPE_PRESENT,GTUBE,HTML_MESSAGE,MPART_ALT_DIFF,
MULTIPART_ALTERNATIVE autolearn=no autolearn_force=no version=4.0.1
X-Spam-Report:

* 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
* 0.7 MPART_ALT_DIFF BODY: HTML and text parts are different
* 1.0 HTML_MESSAGE BODY: HTML included in message

Copied title and URL