How to setup a mail server on Ubuntu 18.04?

0
26268
Email
Email

The email did not need too much presentation as we all sent and received one. There are companies that provide us with the Email service and that is more than enough for the vast majority of users, but there is the possibility of having one on our own server.

Companies are turning to be technologically independent from other large companies and to be the ones that manipulate their data, including the most sensitive ones. However, it is important to bear in mind that depending on the infrastructure and personnel resources, there may be more disadvantages than benefits to taking this option.

In this article we are going to configure a personal mail server on our server with Ubuntu 18.04

Let’s get to work

1.-Upgrading the operating system

This is done to provide the latest software updates and security patches to improve server performance. First we log in as root user:

             sudo -i

1.- Upgrading Ubuntu
1.- Upgrading Ubuntu

As root user, we write:

           apt update && apt -y upgrade

2.- Upgrading the system
2.- Upgrading the system

2.-Installing Postfix

Postfix is a free software/open source mail server, a software program for routing and sending email. It is simple and versatile. We will use it in this tutorial. Run this command on terminal for install it.

            apt install postfix

As soon as you finish the download and installation, we will skip this screen.

3.- Installing postfix
3.- Installing postfix

We chose Internet Site and press enter.

We now place our domain

4.- Configuring postfix
4.- Configuring postfix

And finally the installation is complete

5.- Finishing the installation
5.- Finishing the installation

Once the installation is done we must restart the postfix service.

             systemctl restart

6.- Restarting postfix
6.- Restarting postfix

In case of modifying the values we have placed, we can reconfigure the package with the command:

dpkg-reconfigure postfix

3.-Dovecot’s turn now

Dovecot is an open source IMAP and POP3 server for GNU/Linux / UNIX-like systems, written with security in mind. To install it:

 

8.- Installing Dovecot
8.- Installing Dovecot

And then we start and enable the service:

                systemctl start dovecot

Next:

                systemctl enable dovecot

9.- Starting dovecot
9.- Starting dovecot

4.-Installing SquirrelMail

SquirrelMail is a webmail application created by Nathan and Luke Ehresman and written in PHP. It can be installed on most web servers as long as it supports PHP and the web server has access to an IMAP server and another SMTP server. To download:

            wget https://sourceforge.net/projects/squirrelmail/files/stable/1.4.22/squirrelmail-webmail-1.4.22.zip

10.- Donwloading squirrelmail
10.- Donwloading squirrelmail

Then we decompressed

           unzip squirrelmail-webmail-1.4.22.zip

We proceed to move it inside the web server and change its owner and permissions.

            mv squirrelmail-webmail-1.4.22 /var/www/html/

            chown -R www-data:www-data /var/www/html/squirrelmail-webmail-1.4.22/

and finally:

           chmod 755 -R /var/www/html/squirrelmail-webmail-1.4.22/

11.- Installing squirrelmail
11.- Installing squirrelmail

It’s a good idea to change the name:

             mv squirrelmail-webmail-1.4.22 /var/www/html/squirrelmail

Before using Squirrelmail ask us to configure them. We can do it thanks to the configuration script that comes inside the conf folder.

           perl /var/www/html/squirrelmail/config/conf.pl

12.- Configuring squirrelmail
12.- Configuring squirrelmail

Enter “2” to access the server options

13.- Configuring squirrelmail
13.- Configuring squirrelmail

And now “1” to define the domain.

14.- Entering the domain
14.- Entering the domain

we return by pressing “r”. Enter the general options by typing “4” Then in option “11” change “false” to “true” by typing “y”.

15.-Configuring squirrelmail
15.-Configuring squirrelmail

We leave the script and we have to go to the web browser to verify that the installation has been successful.

             http://IP_SERVER/squirrelmal

 

16.- Squirrelmail on browser
16.- Squirrelmail on browser

5.- creating users for the mail server

To log in from the web interface, we must create a user name and password.

           useradd user1

           passwd user1

17.- Creating users
17.- Creating users

then we create a folder inside the apache location and make it its default folder.

            mkdir /var/www/html/user1

            usermod -m -d /var/www/html/user1 user1

then change the owner of the folder for the new user

             chown -R user1:user1 /var/www/html/user1

19.- Changing owner user1 folder
19.- Changing owner user1 folder

6.- Logging in to SquirrelMail

Finally we access the web interface and log in:

21.- Logging squirrelmail
21.- Logging squirrelmail

And finally we see the interface working.

22.- Squirrelmail
22.- Squirrelmail

Note: If at the moment of logging in with the username and password, you give us an error. It’s most likely an error in permissions.

Spread the love

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here