How to Start an Ubuntu Mail Server – a Complete Beginners Guide

Having your own email server is a great idea for any midsize business. with this, all traffic is controlled and we can define the rules ourselves. in this way we can manage the service in a clear and clean way.

In this tutorial we will show you how to install and configure an ubuntu mail server on a vps server running ubuntu 18.04. there are numerous alternatives and ways to create a mail server in linux; however, we will focus on the postfix!

download the complete linux commands cheat sheet

configuring the dns server for an ubuntu mail server:

Just follow this step-by-step guide, and you shouldn’t have any trouble configuring your settings!

1. log in and update your server

login to your server using ssh. if you have problems, check out our putty tutorial. after logging in, you need to update your machine using the following command:

2. install link

To set up a dns server that will use postfix, we will need an additional tool: bind. let’s install it first:

3. configure /var/cache/db.test

At this point, we must bear in mind that the IP address of our Ubuntu 18.04 machine is 192.168.250.7, it is necessary to replace it with the IP address where we will carry out the installation. for this example, we will use mail.test.com as fqdns.

so now we need to create a new zone for our example. to do this, create a new file with the zone information.

See Also:  21 Local Advertising Ideas to Grow Your Small Business in 2022

then add the following:

Remember, we need to replace the ip address with your server’s, and change the domain to the one you want to use. press ctrl+o to save the changes and ctrl+x to close the nano editor.

4. add a new zone to bind the config

Before enabling the newly created zone it is necessary to verify the configuration file.

Now we can add our new zone to the binding zone configuration file. To do this, run the following command:

and add the new zone:

again, ctrl+o to save changes and ctrl+x to close it.

5. configure /etc/bind/named.conf.options

Now, in the file /etc/bind/named.conf.options it is necessary to uncomment the forwarders line and include the google dns – 8.8.8.8. for that, just remove the // symbols as shown in the screenshot below.

Editing DNS zone to set up an Ubuntu Mail Server

6. Restart Bind

Now, we need to restart the bind9 service. you can do it with one of two commands:

or

how to install and configure mail server on ubuntu 18.04

We are almost there, your ubuntu email server is ready to connect. this is what you should do:

1. install postfix mail server

now it’s time to install postfix. postfix is ​​an email server written in c. its main feature is the speed of execution and the nature of open source. install it with the following command:

See Also:  How to send an anonymous email

During the installation, we will be prompted to configure the package. On the first screen, choose the website option.

then, we have to enter the name of the server. in this case test.com.

postfix is ​​very flexible and allows extensive configuration, but for this tutorial we’ll work around it with the default settings.

2. add user

so, we have to add our user to the group mail:

this must be done because in ubuntu 18.04 only users who are in the mail group can use this utility.

After that, we need to create the users and add them to the mail group so they can send and receive mail. I’ll add gabriel:

then, we need to set a password for the newly created user:

test ubuntu mail server

now to test what we just did. we will send and receive an email from the terminal. for this we will install the package mailutils:

Next, we send an email to the other email account user named gabriel. Write the subject and message. after that, press ctrl+d to finish. To start writing an email enter the following command:

Now we can log in as another user and check the mail utility.

there, after running the mail command, we’ll see the email we just sent to the other test user. To access the email, just write the email number, in this case, 1.

See Also:  Wedding Freebies: A Huge List of Free Wedding Stuff for Your Big Day

To test outgoing emails from this user, try another email address:

that’s it! you are sending email from your own email server on ubuntu 18.04! congratulations.

conclusion

An email server is easy to set up but can be a bit complex to manage. on linux, it is recommended to do so for your security and resource management.

on the other hand, in a larger company, it can be very useful to have a fully configured and functional email server out of the box, like the one offered by hostinger.

There are many ways to improve and maintain an email server. It is a process that takes time and is constantly evolving. so we recommend that you continue delving into the subject! good luck and happy shipping!

Leave a Reply

Your email address will not be published. Required fields are marked *