Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".(Japanese Version)

ArchLinux ; Clamav ( Anti-virus software ) , Mail server

1. Install clamav ( anti-virus software )

1.1 Clam AntiVirus Installation

1.2 Virus definition file update settings

1.3 Virus definition file update

1.4 Clam AntiVirus startup and activation

1.6 Conducted virus scan

Download a test virus and perform a virus scan
If "stdin: Win.Test.EICAR_HDB-1 FOUND" and "Infected files: 1" are displayed, the program is working properly.

1.7 Deployment of virus scan auto-execution scripts

Grant execution permission to scripts

1.8 Virus scan exclusion directory settings

Exclude sys and proc directories.

1.9 Scheduled virus scan execution

Install cronie to make crontab available

To temporarily use vim as a text editor in crontab

To use vim as a text editor in a permanent crontab
Symbolically link with vi

Run a trial script and do a full scan (takes a while)

2. Mail Server (Postfix)

2.1 Installing Postfix

Install Postfix and build an SMTP server

Postfix version check

2.2 Register Postfix to the service

2.3 Edit postfix configuration file

Backup postfix configuration files, and files

To prevent unauthorized mail relay, configure Postfix to require authentication for outgoing mail as well, using Dovecot's SASL function.

2.4 Release SMTP port (port 25)

2.5 Start Postfix

3. Mail Server(Dovecot)

3.1 Dovecot Installation

3.2 Edit dovecot.conf file

3.3 Edit 10-auth.conf file

3.4 Edit 10-mail.conf file

3.5 Edit 10-master.conf file

3.6 Edit 10-ssl.conf file

3.7 Register dovecot as a service and start it

3.8 Permission port opening for POP/IMAP service in UFW

POP is [110/TCP], IMAP is [143/TCP].

4. Create mail user and check operation

4.1 advance preparation

①Pre-processing for new users
When a new user is added, the system is configured to automatically send and receive e-mail.

②Mail environment preprocessing for existing users(huong)
Configure already created users to be able to send and receive mail.

4.2 User Account Creation

Mail client installation

Add user [linux]

4.3 operation check

Log in as an email user and send a test email.

4.4 operation check ②

Set up and confirm your account in Mozilla Thunderbird.
This time, we will use the general user "huong" to set up the account.
① Start Thunderbird, click "Tools", and then click "Account Settings".

②「Account Actions」「Add Mail Account」

③"Your full name" is an optional name
Email addtess" is "" added earlier
"Password" is the password for user huong
Enter each and click "Configure manually".

④Set "INCOMMING SERVER" and "OUTGOING SERVER" as shown below and click "Re-test".

⑤The following settings were found by probinfg the given server

After clicking "Done," the following "Warning" appears, but there is no problem, so click "Confirm"

⑥Click "Finish" when "Account syccessfuly created" is displayed.

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

1. Real-time scanning of email

①clamav-milter configuration

MilterSocketMode 666 ← Specify UNIX socket access rights for clamav-milter
All I see on the internet is "MilterSocketMode 660", but with 660, clamav-milter does not start and I get an error.

However, there is a problem because anyone can read and write in 666. I don't know how to solve this problem

➁Create /etc/systemd/system/clamav-milter.service

➂clamav-milter startup and auto-startup settings

④Postfix and clamav-milter integration settings
Edit Postfix configuration file

⑤Add postfix user to clamav group

⑥Postfix Settings Reflected

⑦TCheck with hunderbird
I sent a blank email to myself in Thunderbird, and in the header display of the received email, I see the following
"X-Virus-Scanned: clamav-milter 1.2.1 at Lepard"

Try sending yourself an email with the body of the email "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*" and confirm that the email is discarded and never received

2. Email spam protection

2.1 SpamAssassin, spamass-milter, and postfix settings

①SpamAssassin installation

➁spamass-milter installation
spamass-milter is available in the aur (arch user repository) software package suite and can be installed using yay.
There is a lot of information on the web about how to install and use yay, so I will skip this section.

➂Start SpamAssassin

If you get the following error
"deprecated method; size() is an alias of "UDPsize()" at /usr/share/perl5/vendor_perl/Mail/SpamAssassin/ line 600."
"/usr/share/perl5/vendor_perl/Mail/SpamAssassin/" Change line 600

SpamAssassin Settings

⑤SpamAssassin configuration file update script
Install the wget command beforehand.

Grant execute permission to the spamassassin-update script and run it

Confirm that the SpamAssassin configuration file ( has been created in the /etc/mail/spamassassin directory with the same date

Set up cron to automatically run a script daily that updates the SpamAssassin configuration file

spamass-milter startup and automatic startup settings

Postfix and spamass-milter integration settings

Restart postfix

⑨Procmail Installation and Configuration
procmail installation
procmail is in the AUR (Arch User Repository) software package group, so use the AUR (Arch User Repository) helper yay to install it.

Create procmail configuration file

Create procmail log rotation configuration file

⑩Postfix and Procmail integration settings

Postfix Settings Reflected

2.2 Spam Mail Filtering Settings

Mail marked as spam in the mail header by SpamAssassin will be delivered to a spam-only mailbox, while other mail will be delivered to a normal mailbox.

①Create a dedicated spam mailbox
For existing users, add a spam-only mailbox to their mailboxes.
For new users, a spam-only mailbox will be automatically created when a user is added.

➁Created script to create spam-only mailboxes

Run script to create spam-only mailboxes

Measures for new users
Automatic spam-only mailbox creation when adding new users

spam filtering
Emails identified as spam by SpamAssassin are delivered to a spam-only mailbox.

spamass-milter confirmation
When you send a blank email to yourself, the following message is appended to the header of the received email
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on Lepard

⑥Spam check confirmation
Send yourself an email with the body of the email "XJSC4JDBQADN1.NSBN32IDNENGTUBE-STANDARD-ANTI-UBE-TEST-EMAILC.34X" and make sure the email is not delivered and is sorted into the Spam folder

Copied title and URL