Ubuntu: Set up mail server - how it works
In this practical tip, we will show you how to set up your own mail server on Ubuntu. Having your own mail server offers advantages not only for business purposes. For example, you can set the maximum size of the attachment and much more.
Requirements for the mail server:
You should first set up your Ubuntu PC as a standalone server. You can read about how this works in the practical tip Setting up Ubuntu as a server. You also need your own domain that your mail server can run on. You can use our practical tip on various domain providers to help you with this.
Set up mail server on Ubuntu
First you need the right software. You can easily install this via the terminal by calling it up with [CTRL] + [ALT] + [T].
- If not already installed, install the aptitude application with "sudo apt install aptitude".
- Then request another update with the "sudo apt-get update" command.
- The next step is to install the actual package. It contains the programs "dovecot" and "postfix" which lay the basic building blocks for your mail server. This is done with the command "sudo apt-get install mail-stack-delivery".
- During the installation you will be asked to define some configurations. First you have to choose the general type of configuration, there you select "Internet site".
- In the next step you will be asked to define your domain. In our example this is "nslotta.de".
Ubuntu mail server: configuration of Postfix
Now you have to determine which email address belongs to which user for your mail server. To do this, you need to edit the Postfix config file:
- You can do this with the command "sudo nano /etc/postfix/main.cf".
- Insert the line "virtual_alias_maps = hash: / etc / postfix / virtual" there. This refers to the corresponding file which later specifies which email address belongs to which user.
- Save the file with [CTRL] + [O] and then close it with [CTRL] + [X]
- Now create the corresponding file by changing to the directory: "cd / etc / postfix" and then entering the command "sudo nano virtual".
- Now enter the email address and then the user. In our case " chip"
- Activate the whole thing with "sudo postmap virtual" and then restart Postfix with "/etc/init.d/postfix restart".
- Please make sure to store the corresponding MX entries with your provider for the domain.
- Tip: If you want to revise all configurations of Postfix again, you can do this with the command "dpkg-reconfigure postfix".