Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".

Ubuntu Server 18.04 ; Mail Server Install

1.Postfix : Installation / Configuration

Postfix is a software developed as an MTA (Mail Transport Agent) to replace Sendmail, and is a mail server with features such as high compatibility with Sendmail, security, easy maintenance, and speed.
Also, since Postfix only functions as an SMTP server for sending mails, you will need to install a POP server for receiving mails separately as described later.

1.1 Install

Install Postfix and build an SMTP server. 25/TCP is used for SMTP.

1.2 Edit configuration file

①Edit main.cf

Reflect and activate the settings.

②Edit master.cf

Reflect and activate the settings.

2. Dovecot : Installation/Configuration

Dovecot is a server for receiving mail (POP).
Install Dovecot and set up a POP/IMAP server, using 110/TCP for POP and 143/TCP for IMAP.

2.1 Install

①Configure Dovecot so that Postfix can provide SASL functionality.

②Edit the configuration file "dovecot.conf".

③Edit the configuration file "10-auth.conf".

④Edit the configuration file "10-mail.conf

⑤Edit the configuration file "10-master.conf

⑥restart

3. Register for an email user account

Register for an email user account
This is the setting to use a user account on the OS for email as well.
If you want to use e-mail with a user account on the OS, no additional settings are required, just register the OS user
①Mail client installation

②Configure mailboxes to refer to Maildir.

③Add an OS user [e.g., hoge]

④Test sending email
Log in with the user account you added and test sending mail.
Send a test mail to yourself [mail (user name)@(host name)]

Confirmation of incoming mail

4. Apply ClamAV to mail server Postfix

Configure Postfix and Clamav to work together to scan incoming and outgoing mails in real time.

It is assumed that Clamav is already installed.
Install Amavisd and Clamav Daemon and start Clamav Daemon.

① Install

② Enable virus scan

③ Register your own domain name

④ Edit the configuration file "main.cf".

⑤ Edit the configuration file "master.cf".

⑥ restart

⑦ Check with Thundwebird and npop.

The following header is added to the incoming and outgoing e-mails. If a virus is detected, it will be removed and not delivered to the client.

 

5. Install spamassassin on  Postfix

① Install

There is a file "/etc/mail/spamassassin/local.cf", so use it by default without any additional settings.

② Create a Maildir for storing spam mails
Create a directory ".Spam" in the Maildir format for storing spam mails.
To create it, use the target user (e.g., hoge).
Log in as the target user.

③ Prep for Procmail

Check if Procmail is installed on the server machine.

If it is installed, the following results will be returned.
procmail/bionic,now 3.22-26 amd64 [installed]

Find the path to Procmail with the following command

The path to Procmail is shown.
/usr/bin/procmail

④ Procmail Configuration
If you put it in "/etc/procmailrc", which controls the entire mail filter, it will be applied to all users.
If you put it in "/home/<username>/.procmailrc", which is a mail filter file for each user, the filter will be applied only to that user.
In this case, we will write it in "/etc/procmailrc" in order to apply it to all users.

⑤ Postfix Configuration

⑥ Start SpamAssassin and restart Postfix.

⑦ confirmation

Send an email to your domain.
If you see the following description in the header of the mail, the settings have been made correctly.
The following header is a description of a mail that is judged to be spam.

・・Abbreviation・・・
X-Spam-Flag: YES
X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on mail.example.com
X-Spam-Report:
* 0.1 HTML_60_70 BODY: Message is 60% to 70% HTML
* 0.0 HTML_MESSAGE BODY: HTML included in message
・・Abbreviation・・・
X-Spam-Status: Yes, hits=8.2 required=5.5 tests=CLICK_BELOW,
FORGED_RCVD_NET_HELO,HTML_60_70,HTML_FONTCOLOR_UNSAFE,
HTML_IMAGE_ONLY_08,HTML_LINK_CLICK_HERE,HTML_MESSAGE,QENCTXT
autolearn=no version=2.64
X-Spam-Level: ********
・・・Abbreviation・・・

If you see the above "X-Spam-***" in the mail header, SpamAssassin is working properly.
If you see "X-Spam-Status: Yes", the message is considered spam.
On the other hand, if the message has "X-Spam-Status: No", it will be judged as a normal message.

⑧ Learning about spam emails
SpamAssassin has the ability to learn about your email and improve the accuracy of its decisions.

⑨ Learning to send regular emails

⑩ Automatic execution of mail judgment

Create a mail judgment script and register it to Cron.
Save the file as "/usr/local/bin" and name it "spam-learns.sh".
After saving the script, give it executable access as "chmod 750 spam-learns.sh".

Register for automatic execution of services
Automatically start SpamAssassin on system startup
Copied title and URL