業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

OpenSUSE16.0 : Clamav , Mail Server

1. ClamAV (antivirus software) implementation

1.1 Install ClamAV
1.2 Definition File Update

①Virus Definition File Update Settings

②Virus definition file update

Finally, the message "WARNING: Clamd was NOT notified: Can't connect to clamd through /run/clamav/clamd-socket: No such file or directory" appears, but this is not a problem.

1.3 Functionality Verification

①If no virus is detected

➁When a virus is detected
Download the test virus and scan it

1.4 Implementation of an Automatic Virus Scan Script

①Creating the Script Storage Directory

②Automatic Script Creation

Create clamscan.sh in /srv/www/system with the following content:

Grant execution permissions to the script

The sys directory and proc directory cannot be scanned per specification, so exclude them.
Also, openSUSE creates a large number of snapshots, so exclude it.

Scheduling Regular Virus Scans
Install cronie

Run "/srv/www/system/clamscan.sh" to scan the entire system.

2. Mail Server Installation

2.1 Postfix Installation

①Install Postfix to build an SMTP server.

②Postfix Configuration
To prevent unauthorized mail relaying, configure Postfix to require authentication for outgoing mail using the SASL feature of Dovecot, described later.

③If Firewalld is enabled, you must allow the SMTP service. SMTP uses port 25/TCP.

2.2 Dovecot Installation

Installing from the official repository will install Dovecot 2.4.1, but the configuration file for Dovecot 2.4.1 is difficult to write and beyond my capabilities. Therefore, I will deliberately add the unofficial repository for Dovecot 2.3 published on the community site for openSUSE 16 and install Dovecot 2.3 (Dovecot 2.3.21 will be installed).

①Adding a repository

➁Install

➂Dovecot Configuration
Configure Dovecot to enable SASL functionality for Postfix.

④Dovecot Startup and Automatic Execution

⑤If Firewalld is enabled, you must allow POP/IMAP services.
POP uses port 110/TCP, and IMAP uses port 143/TCP.

2.3 User Account Registration

This time, we will register the OS user "huong".
① Install the email client

②The mailbox is configured to reference Maildir.

※If a Maildir directory has not been created in the home directory of the existing user (huong), create it manually as follows:

2.4 Operation Verification

Configure your account in the free email client Thunderbird and verify it works.
However, depending on your provider, the outgoing server may use port 587, so make sure to open port 587 in your firewall settings.

Set up and verify your account in Mozilla Thunderbird (for OS user huong as an email user)
Launch Thunderbird, click [New Account] > [Email] in the [three-bar] menu at the top right

Full name: Any name
Email address: huong@[domain name]
Enter each field and click "Continue".

Click [EDIT CONFIGURATION]

Incoming Server Settings
Set [Connection security] to [None] and click [Continue]

Outgoing Server Settings
Set [Connection security] to [None] and click [Test]

Click [Continue]

Enter the user's password in the [Password] field and click [Continue].

Click [Continue]

Your email account has been successfully created. Click [Finish].

3. Mail Server : Postfix + Clamav + clamav-milter+SpamAssassin

3.1 Real-time email scanning

①clamav-milter Installation
Perform virus checks on emails at the mail server side using Clam AntiVirus.
Integration between the mail server and Clam AntiVirus is achieved using clamav-milter.

➁clclamav-milter configuration
Editing the clamav-milter configuration file
Regarding the UNIX socket permissions for clamav-milter, most sources recommend setting them to "660". However, in my environment, this caused it to fail to start. Although it poses a security risk, I set them to "666".

➂clamav-milter startup and automatic startup configuration

④Postfix and ClamAV-Milter Integration Configuration
Editing the Postfix Configuration File

⑤Add the postfix user to the clamilt group
For some reason, the clamilt group user wasn't created during installation, so I'll create it now.

Add the postfix user to the clamilt group

⑥Postfix Configuration Update

⑦Check in Thunderbird
Send an empty email to yourself in Thunderbird. In the header display section of the received email, the following should appear:
X-Virus-Scanned: clamav-milter 1.4.3 at lepard
X-Virus-Status: Clean

X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: <xxxxx@xxxxxxx.com>
X-Original-To: xxxxx@xxxxxxx.com
Delivered-To: xxxxx@xxxxxxx.com
Received: from [192.168.11.6] (buffalo.setup [192.168.11.1])
by mail.xxxxxxx.com (Postfix) with ESMTPA id 4B4E6D2D1
for <xxxxx@xxxxxxx.com>; Mon, 06 Oct 2025 19:05:40 +0900 (JST)
Message-ID: <62b016f4-f943-4d28-a0db-80fca430dd70@xxxxxxx.com>
Date: Mon, 6 Oct 2025 19:05:40 +0900
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: xxxxx <xxxxx@xxxxxxx.com>
Content-Language: en-US
To: xxxxx <xxxxx@xxxxxxx.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: clamav-milter 1.4.3 at lepard
X-Virus-Status: Clean

Send yourself an email with the body text "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*" and verify that the email is discarded and does not arrive.

3.2 Email Spam Prevention
3.2.1 SpamAssassin・spamass-milter・postfix Settings

①SpamAssassin・spamass-milter install

spamass-milter was not found in the official repository, so we have added an experimental one to the repository and installed it.

➁SpamAssassin startup

➂SpamAssassin Configuration

④SpamAssassin Configuration File Update Script
Create script under /etc/cron.daily

Grant the spamassassin-update script execution permissions and run it.

Verify that the SpamAssassin configuration file (local.cf) has been created with the current date in the /etc/mail/spamassassin directory.

⑤SpamAssassin Milter Startup and Automatic Startup Configuration

⑥Postfix and SpamAssassin Milter Integration Configuration

⑧Restart postfix

⑨Procmail Configuration
Creating a Procmail Configuration File

Creating the Procmail Log Rotation Configuration File

⑩Postfix and Procmail Integration Configuration

Postfix Configuration Update

3.2.2 Spam Email Filtering Settings

Emails marked as spam by SpamAssassin in their headers should be delivered to the spam-specific mailbox, while other emails should be delivered to the regular mailbox.

①Creating a Dedicated Spam Mailbox
For existing users, add a dedicated spam mailbox to their mailbox.
For new users, automatically create a dedicated spam mailbox when adding the user.
Create a script for creating dedicated spam mailboxes.

Execute the spam-dedicated mailbox creation script

New User Countermeasures
Automatically create a dedicated spam mailbox when adding new users

➁Spam Email Filtering
Emails flagged as spam by SpamAssassin are delivered to a dedicated spam mailbox.

➂SpamAssassin Milter Verification
When sending an empty email to yourself, the following message is appended to the header of the received email:
X-Spam-Status: No, score=2.2 required=8.0 tests=ALL_TRUSTED,
CONTENT_TYPE_PRESENT,EMPTY_MESSAGE autolearn=no autolearn_force=no
version=4.0.1
X-Spam-Level: **
X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lepard

X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: <xxxxx@xxxxxxx.com>
X-Original-To: xxxxx@xxxxxxx.com
Delivered-To: xxxxx@xxxxxxx.com
Received: from [192.168.11.6] (buffalo.setup [192.168.11.1])
by mail.xxxxxxx.com (Postfix) with ESMTPA id 05DF5D432
for <xxxxx@xxxxxxx.com>; Tue, 07 Oct 2025 09:49:00 +0900 (JST)
Message-ID: <87078198-4413-4907-a72a-0dd7500d1c00@korodes.com>
Date: Tue, 7 Oct 2025 09:48:59 +0900
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: huong <xxxxx@xxxxxxx.com>
Content-Language: en-US
To: huong <xxxxx@xxxxxxx.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: clamav-milter 1.4.3 at lepard
X-Virus-Status: Clean
X-Spam-Status: No, score=2.2 required=8.0 tests=ALL_TRUSTED,
CONTENT_TYPE_PRESENT,EMPTY_MESSAGE autolearn=no autolearn_force=no
version=4.0.1
X-Spam-Level: **
X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on Lepard

④Spam Check Verification
Confirm that an email with the body text "XJSC4JDBQADN1.NSBN32IDNENGTUBE-STANDARD-ANTI-UBE-TEST-EMAILC.34X" sent to yourself is not delivered and is instead routed to the Spam folder.
The email header displays as follows:

Return-Path: <xxxxx@xxxxxxx.com>
X-Original-To: xxxxx@xxxxxxx.com
Delivered-To: xxxxx@xxxxxxx.com
Received: from [192.168.11.6] (buffalo.setup [192.168.11.1])
by mail.xxxxxx.com (Postfix) with ESMTPA id A8698D433
for <xxxxx@xxxxxxx.com>; Tue, 07 Oct 2025 09:53:05 +0900 (JST)
Content-Type: multipart/alternative;
boundary="------------bXIP72VG7BUq5TDt8w65TTDf"
Message-ID: <25095fa1-94da-4024-a2a2-eca90c5d91f9@korodes.com>
Date: Tue, 7 Oct 2025 09:53:05 +0900
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: xxxxx <xxxxx@xxxxxxx.com>
Content-Language: en-US
To: xxxxx <xxxxx@xxxxxxx.com>
Subject: Spam Test
X-Virus-Scanned: clamav-milter 1.4.3 at lepard
X-Virus-Status: Clean
X-Spam-Flag: YES
X-Spam-Status: Yes, score=1003.3 required=8.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 MULTIPART_ALTERNATIVE Multipart/alternative
* -0.1 CONTENT_TYPE_PRESENT exists:Content-Type
* 1000 GTUBE BODY: Generic Test for Unsolicited Bulk Email
* 2.2 MPART_ALT_DIFF BODY: HTML and text parts are different
* 1.0 HTML_MESSAGE BODY: HTML included in message
X-Spam-Level: **************************************************
X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lepard
Copied title and URL