articles » current » information-technology » linux » setup-and-configure » ubuntu-mail-server

Ubuntu Mail Server

Setup a Ubuntu 14.04 mail server

Download Ubuntu server 14.04 from here. It has to be version 14.04. This tutorial only covers this version.

Start the Ubuntu server install.

When asked for the hostname enter

When asked to setup users and passwords, enter a user's full name.

Enter a username and password.

When asked how to manage upgrades select no automatic updates.

When asked to choose software to install do not install any. Mail server software will be installed after the installation of the operating system.

After the installation is complete and the system has rebooted, enter the username and password created during the installation.

The network card now needs to be setup. Login as root by issuing a sudo su command. Enter cat /etc/network/interfaces. If iface eth0 inet dhcp is written then this will need to be changed to iface eth0 inet static. Issue a nano /etc/network/interfaces command to edit this file.

Change dhcp to static. Enter the address, netmask, network, broadcast, gateway, dns-nameservers, and dns-search values. Save the file by hitting ctrl-O and then exit nano by hitting ctrl-X.

Edit the /etc/hosts files using nano (issue a nano /etc/hosts command). Update the IP address for Save the file and exit.

Now update and upgrade the system. Issue a apt-get update command. The system will update. Next, issue a apt-get upgrade -y command. Wait for the files to download and install. Finally, issue a apt-get dist-upgrade -y command. Wait again for the files to download and install. Issue a reboot command.

Login. Now it is time to install the SMTP mail server called Postfix. Issue a sudo apt-get install postfix -y command. This will install postfix onto the server.

When asked about the type of mail configuration, choose Internet Site.

When asked about the system mail name, enter the domain name.

Now it is time to reconfigure postfix. Issue a sudo dpkg-reconfigure postfix command.

Select Internet Site again. Hit enter. Leave the domain as previously entered. Hit enter.

When asked about the Root and postmaster mail recipient enter the username of the one user setup in the system.

When asked for Other destinations to accept mail for just hit enter to accept the values already entered.

When asked to Force synchronous updates on mail queue answer no.

When asked for Local networks enter the network here. For this example, the network is Hit enter.

For Mailbox size limit just leave the value at zero. For Local address extension character just leave a plus sign.

For Internet protocols to use select ipv4.

Now, edit the /etc/postfix/ file using nano (issue command sudo nano /etc/postfix/

Page down to the end of the file and enter these properties:

Save the file and exit.

Now it is time to create the certificate that the mail server will use. Enter the commands below exactly as they are entered here except that the domain should be the domain used above.

Now, enter this command. The 3650 refers to how many days the certificate will be good (10 years).

Now copy the cert and key files to the directories listed below.

Issue the following postconf commands:

Use nano to modify /etc/postfix/ Remove the hash symbols to match below.

Now it is time to install Dovecot which is the mail retrieval service. It provides POP3 and IMAP access.

After dovecot downloads and installs, it will ask if a self-signed SSL certificate is needed. Answer YES.

Next, it will ask for the host name. Enter

After hitting enter, dovecot will finish setting up.

Next, some dovecot files need to be modified. Use nano to edit /etc/dovecot/conf.d/10-master.conf.

Page down to the section that reads # Postfix smtp-auth and remove the three hash symbols below # Postfix smtp-auth. Modify the code to look like this and notice that mode = 0660 not 0666:

Use nano to modify /etc/dovecot/conf.d/10-auth.conf. Find auth_mechanisms = plain and change it to auth_mechanisms = plain login. Save and exit.

Restart the postfix and dovecot services.

Next, install dovecot's IMAP and POP3.

Use nano to modify /etc/dovecot/conf.d/10-mail.conf. Find mail_location = and change it to read as below.

Save and exit.

Use nano to modify /etc/dovecot/conf.d/20-pop3.conf. Find #pop3_uidl_format = and remove the hash just as below.

Save and exit.

Use nano to modify /etc/dovecot/conf.d/10-ssl.conf. Find #ssl = yes and remove the hash and change it to required as below.

Save and exit.

Issue a sudo service dovecot restart command to adopt the changes made to the configuration files.

To see the ports that the mail server is listening on use the command netstat -nl4. These ports should be opened up on the firewall.

This site uses cookies. Cookies are simple text files stored on the user's computer. They are used for adding features and security to this site. Read the privacy policy.