Paypal donation


Configure a Dedicated Server with Webmin

Part 10 - Email server

01-Introduction - 02-Installing Webmin - 03-Configure DNS - 04-Assign Nameservers - 05-Configure SFTP - 06-Setup Web server - 07-Let's Encrypt - 08-Setup Perl/CGI PHP - 09-Manage MySQL - [[ 10-Setup Email server ]] - 11-Setup SASL - 12-Setup Email accounts - 13-Email process - 14-Email antivirus - 15-Usermin - 16-Extras

Setting up an email server for our website is the most complicated.
Make sure you really need a hosted email server by you before doing this step.
We will set up a configuration shown below :
Email design diagram

The "email process" section will be covered in a later chapter of this ebook.
The core of the server is done by a so called Mail Transfer Agent (MTA).
We are going to use Postfix as MTA in our setup.
An older less secure MTA was sendmail but most modern systems use Postfix.
Postfix will listen to the Port 587.
This port is used for the so called: Simple Mail Transfer Protocol - Mail Submission Agent.
SMTP is a protocol for sending emails over the Internet.
MSA requires that clients are authorized and authenticated in order to sent mails.

In order to deliver emails you need a MDA (Mail Delivery Agent).
We are going to use Dovecot with IMAPS protocol.
Internet Message Access Protocol (over SSL) is a secure email protocol used for accessing emails on a remote mail server from a local client.
For retrieving messages, email client applications, also called Mail User Agents (MUA), usually use either POP3 or IMAP.
We will cover only the IMAP protocol since it is more powerful than the POP3.
IMAP stores all emails at the server instead POP3 downloads all emails to the client and after that deletes them from the server.
If you have more physical devices connected on the same email account, like nowadays, IMAP protocol is a better option since it allows you to synchronize all of your devices at once.
Using POP3 instead you have to synchronize your devices manually.
Notice that Dovecot also supports the POP3 communication protocol.


We will use Thunderbird as email client (MUA) .
Using the Port 993 (IMAPS) we can deliver our emails from Dovecot to our email client.
Before starting, if you followed this ebook, you should have already created a MX record like mail.website1.com for your zone website1.com. If not take a look again at the DNS section.

Installations

Log in to your dedicated server using PuTTY. Make sure you remove sendmail.

yum remove sendmail sendmail-cf sendmail-doc

Install Postfix:

yum install postfix

Install Dovecot:

yum install dovecot

If for some reason you want to un-install Postfix and / or Dovecot :

yum -C remove postfix
yum -C remove dovecot

Notice that both of the modules can be also installed from Webmin Web interface under the Un-used Modules section.

From Webmin go to System > Bootup and Shutdown.
Check dovecot, postfix and press the Start on Boot button.
start on boot dovecot and postfix

Firewall Configuration

From Webmin go to Networking > Linux Firewall.
Under Incoming packets (INPUT) - Only applies to packets addressed to this host, find and click on the "Add Rule" button.
firewall configuration

In the "Add Rule" page fill like this :

Set "Action to take" to Accept
‰As "Network protocol", select Equals and TCP
‰As "Destination TCP or UDP port", select Equals and set Port(s) to 587

‰Click the "Create" button on the bottom of the page.
firewall configuration

Do the same for the port 993
Notice that the port 25 is not needed to be open since we are going to use only secure connections on our server.

So as final result you should have under "Incoming packets (INPUT) - Only applies to packets addressed to this host" something like the photo below
firewall configuration

Click on the "Apply Configuration" button in order to apply your firewall rules.
After doing this go to Kimsufi manager and press the "Restart" button in order to do a hardware restart of your machine.


Postfix Configuration

Go to Servers > Postfix Mail Server and click over the "General Options" icon.
postfix configuration Fill the "General Options" page like this :
Set "What domain to use in outbound mail" to: Use domainname.
Set "What domains to receive mail for" to: Whole domain.
Set "Network interfaces for receiving mail" to All.
Set "Internet hostname of this mail system" to mail.website1.com
Notice that this hostname will be our base host name for all other email domains hosted in our server.
Set "Local internet domain name" to Default.
This sets the mail domain to the hostname without the first component. In our case, this would be website1.com
Make sure that "Mail queue directory" is set to : /var/spool/postfix.
postfix configuration second part

Click the "Save and Apply button".
Click the "Stop Postfix" and then the "Start Postfix" button to restart the mail system.

Test your Postfix mail server by logging at your server using PuTTY and writing the command :

echo "TestEmail" | mail -s yoursubject freemail@yahoo.com

Control your freemail@yahoo.com. Control also your spam folder if you can not find the mail. Postfix should have sent the email.

Configure Dovecot

Till now our web server is capable of sending messages using Postfix.
Let's see now how we can receive emails with the help of dovecot.
Navigate to Servers > Dovecot IMAP/POP3 Server Now click over the Networking and Protocols icon.
dovecot protocols

Under "Dovecot networking and mail protocol options" at the "Networking and Protocols" page do like so:

In the Serve mail protocols, select IMAP.
Leave the rest at the defaults settings.

dovecot settings

Click the "Save" button.
Now hit over the "Return to module index" link
Click over the "Mail Files" icon.
dovecot mail files

At "Mail Files" page do like this :

Mail file location : Inbox and folders in ~/Maildir
Set UIDL format to Other, and enter : %08Xu%08Xv in the text field.
Left all other settings as is.

Click the "Save" files.
Now hit over the "Return to module index" link

dovecot mail files configuration

Click over the "SSL Configuration" icon.
dovecot ssl configuration

At "SSL Configuration" page, under "IMAP and POP3 SSL mode options" do like this :

Copy at notepad the SSL certificate file, ex : /etc/pki/dovecot/certs/dovecot.pem
Copy at notepad the SSL private key file, ex: /etc/pki/dovecot/private/dovecot.pem
Set Disallow plaintext authentication in non-SSL mode? to Yes.

Click the "Save" button.
Now hit over the "Return to module index" link

dovecot ssl configuration page
Click the "Apply Configuration" button.


In the next section we will discuss how Postfix and dovecot will authenticate using SASL.

01-Introduction - 02-Installing Webmin - 03-Configure DNS - 04-Assign Nameservers - 05-Configure SFTP - 06-Setup Web server - 07-Let's Encrypt - 08-Setup Perl/CGI PHP - 09-Manage MySQL - [[ 10-Setup Email server ]] - 11-Setup SASL - 12-Setup Email accounts - 13-Email process - 14-Email antivirus - 15-Usermin - 16-Extras


Copyright © TrustFm.net 1998-2017 - Made by TrustFm - All Rights Reserved Worldwide