How to setup a mail server on Ubuntu 18.04?

Windows Articles

Monitoring Ubuntu 20.04 with Stacer

Normally if we use Linux on a production server, it is important to monitor it. On the other hand, in everyday use, many users...

How to get the Android 11 Notification Panel

It's no secret that even though Android is the most widely used mobile operating system. Not always our device has the latest...

How to create backups in Windows 10 with FileFort Backup

There is no doubt that the computer is an essential element in our lives. Indeed, its uses go beyond work or study....

Trisquel 9.0 available

Trisquel is a GNU/Linux distribution endorsed and supported by the Free Software Foundation. This means that in addition to incorporating the Linux...

How to install PandoraFMS on CentOS 8?

Worldwide many IT infrastructures are running Linux on one of their servers. This opens the door to an endless number of different...
angeloma
angeloma
Senior Writer and partner

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.

More articles

15 COMMENTS

  1. When I try to do step 11, it says “mv: cannot move ‘squirrelmail-webmail-1.4.22’ to ‘/var/www/html/’: No such file or directory” HELP

    -I’ve done all of the previous steps successfully, why is this one NOT working?

  2. Error opening ../data/default_pref
    Could not create initial preference file!
    /var/local/squirrelmail/data/ should be writable by user www-data
    Please contact your system administrator and report this error.

  3. I get this at step 5:

    root@mail:/var/www/html/squirrelmail/config# usermod -m -d /var/www/html/user3 user3
    usermod: directory /var/www/html/user3 exists

  4. I have setted up everything. Every thing is working correctly but I can only receive email but cannot sent any email from it

  5. I have checked the file and it’s there so I don’t know why i’m getting this error message “ERROR: Config file ‘ . ‘”config/config.php” not found. You need to ‘ . ‘configure SquirrelMail before you can use it.
    ‘; exit; } // If we are, go ahead to the login page. header(‘Location: src/login.php’); ?>”

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Monitoring Ubuntu 20.04 with Stacer

Normally if we use Linux on a production server, it is important to monitor it. On the other hand, in everyday use, many users...

How to get the Android 11 Notification Panel

It's no secret that even though Android is the most widely used mobile operating system. Not always our device has the latest...

How to create backups in Windows 10 with FileFort Backup

There is no doubt that the computer is an essential element in our lives. Indeed, its uses go beyond work or study....

Trisquel 9.0 available

Trisquel is a GNU/Linux distribution endorsed and supported by the Free Software Foundation. This means that in addition to incorporating the Linux...

How to install PandoraFMS on CentOS 8?

Worldwide many IT infrastructures are running Linux on one of their servers. This opens the door to an endless number of different...
x