Setup Email Server Ubuntu 18.04

Setup Email Server Ubuntu 18.04

Setting up your own email server will help you control the traffic, manage the service, and protect your privacy by storing all your emails on the email server. But before you going to set up an email server on Ubuntu 18.04, you need to configure the DNS server. So, just follow the below instructions to setup email server Ubuntu 18.04.

Configure Dns Server On Ubuntu 18.04

  • Step :1 First, log in to your account using SSH (secure protocol).
  • Step :2 Now, open the Terminal window and update the APT package repository cache using the below command.
  • apt-get update
  • Step :3 To configure the DNS server, you need to install an additional tool called, Bind9. Follow the below command to install it.
  • sudo apt install bind9
  • Step :4Next, press the Y and Enter keys on your keyboard to proceed.
  • Step :5The Bind9 tool will now be installed.
  • Step :6Follow the below command to create a new file zone.
  • sudo nano /var/cache/bind/db.test
  • Step :7Now, add the following command lines and replace “192.168.250.7” with your computer's IP address and replace test.com with your domain name.
  • $ORIGIN test.com. $TTL 1D @ IN SOA ns1 root( 1 ;serial 1D ;refresh 2H ;retry 2W ;expire 5H ;minimum ); @ IN NS ns1 ns1 IN A 192.168.250.7 mail IN A 192.168.250.7 @ IN MX 5 mail
  • Step :8Press the CTRL + O keys to save the changes and hit the CTRL + X keys to exit the nano editor.
  • Step :9Now, check the configuration file by following the below command.
  • sudo named-checkzone test.com. /var/cache/bind/db.test
  • Step :10Add a new file to the Bind zone configuration file by running the following command.
  • sudo nano /etc/bind/named.conf.default-zones
  • Step :11Next, configure your DNS zone by adding the below line.
  • zone "test.com." { type master; file "db.test"; };
  • Step :12Press the CTRL + O keys to save the changes and hit the CTRL + X keys to close the nano editor.
  • Step :13Edit the “/etc/bind/named.conf.options” file path by following the below command.
  • sudo nano /etc/bind/named.conf.options
  • Step :14Next, uncomment the forwarders line and change 0.0.0.0 to the Google DNS –8.8.8.8.
  • Uncomment The Forwarders Line
  • Step :15Restart the Bind9 service by running the below command.
sudo systemctl reload bind9 (or) sudo systemctl restart bind9

Install The Postfix Email Server On Ubuntu 18.04

  • Step : 1 Run the following command to install postfix.
  • sudo apt install postfix
  • Step : 2 You will now be prompted to configure the package. Select the Internet Site option.
  • Select The Internet Site Option
  • Step : 3 Add your user name to the group mail to send and receive mail by following the below command.
  • sudo usermod -aG mail $(whoami) sudo useradd -m -G mail -s /bin/bash/ name
  • Step : 4 In the above command, replace the word “name” with the user name (your name).
  • Step : 5 Now, set a password to the newly created user name by running the below command.
  • sudo passwd name
  • Step : 6 Again, replace the word “name” with the user name (your name).
  • Step : 7 To send and receive an email from the terminal, you need to install the mailutils package by running the below command.
  • sudo apt install mailutils
  • Step : 8 Now, start writing an email by following the below command.
mail name@test.com

You can setup email server Ubuntu 18.04 by following the above instructions.

mail settings net