Email Setup Center
  • Home »
  • Postfix Mail Server Configuration In Ubuntu

Get Postfix Mail Server Configuration In Ubuntu Step By Step

Postfix is an open-source MTA (Mail Transfer agent) that allows you to send and receive emails on a Linux-based OS. Ubuntu is a Linux distribution and open-source software. This section explains how to get a Postfix mail server configuration in Ubuntu step by step. Make sure to perform the below steps correctly to configure Postfix properly in Ubuntu.

Step 1: Install Postfix

Generally, the Postfix mail server is stored in the default repositories of Ubuntu. Before installing Postfix, you need to update the local apt package by running the following command in the Terminal window:

$ sudo apt-get update

You can also add the following variable to the installation command:

Postfix Mail Server Configuration In Ubuntu Step By Step

$ sudo DEBIAN_PRIORITY= low apt-get install postfix

In the prompts, you’ll be asked to enter the following information:

  • Step 1:General type of mail configuration
  • Step 2:System mail name
  • Step 4:Other destinations to accept mail for
  • Step 5:Force synchronous update on mail queue
  • Step 6:Local networks
  • Step 7:Mailbox size limit
  • Step 8:Local address extension character
  • Step 9:Internet protocols to use

To modify the above settings later, use the $ sudo dpkg-reconfigure postfix command.

Step 2: Improve the Postfix configuration settings

  • Step 1:You need to set up some variables for the packages that don’t prompt. Use the Maildir format and set a variable called home_mailbox to it. And move on to the next steps to get Postfix mail server configuration in Ubuntu step by step.
  • Step 2:To query a set of configuration settings, use the postconf command.
  • Step 3:If you wish to configure the home_mailbox variable, then type $ sudo postconf –e home_mailbox= Maildir/ and run it.
  • Step 4:To map your arbitrary email accounts to Ubuntu system accounts, set a location in the table called virtual_alias_maps. Make sure to create the virtual_alias_maps table at /etc/postfix/virtual. Use the postconf command to set the location.$ sudo postconf –e virtual_alias_maps= hash:/etc/postfix/virtual.

Step 3: Map Mail Addresses to Ubuntu accounts

  • Step 1:To map mail addresses to the Ubuntu account, you need to open the virtual maps file in a text editor first.
  • Step 2:Run the $ sudo nano /etc/postfix/virtual command.
  • Step 3:Now, map the mail address to Ubuntu account in the following format: “EMAIL ADDRESS THAT YOU WISH TO ACCEPT” “LINUX USER NAME THAT YOU’D LIKE THE MAIL DELIVERED TO.”
  • Step 4:Once you have mapped all the mail addresses to the Ubuntu account, save and close the map file. To apply the map settings, use the following command:$ sudo postmap /etc/postfix/virtual
  • Step 5:Now, restart the Postfix mail process in Ubuntu by running the following command: $ sudo systemctl restart postfix and get Postfix mail server configuration in Ubuntu step by step.

Step 4: Allow Postfix through the firewall

  • Step 1:If you’re using the UFW firewall on your Ubuntu computer, then you need to manually allow Postfix service by typing the $ sudo ufw allow Postfix command.
  • Step 2:Now, the Postfix server will be installed on your Ubuntu computer.

Step 5: Set the MAIL environmental variable correctly

  • Step 1:Before configuring clients with the Postfix server, it is necessary to configure the mail environmental variable correctly and then get your Postfix mail server configuration in Ubuntu step by step.
  • Step 2:Add the variable to /etc/bash.bashrc and a file within /etc/profile.d in order to access your account in different locations.
  • Step 3:Use the $ echo export MAIL=~/Maildir | sudo tee –a /etc/bash.bashrc | sudo tee –a /etc/profile.d/ command.
  • Step 4:If you wish to read the variable in the current session, then use the $ source /etc/profile.d/ command.

Step 6: Configure the Mail Client on your Ubuntu computer

  • Step 1:Install the s-nail package on your Ubuntu computer using the $ sudo apt-get install s-nail command.
  • Step 2:Open the /etc/s-nail.rc file to make changes to the account settings. You can run the following command: $ sudo nano /etc/s-nail.rc
  • Step 3:Now, a list of commands will load. Scroll down the page and navigate to the bottom of the command window.
  • Step 4:Add the following options to the command to get Postfix mail server configuration in Ubuntu step by step.
  • Step 5:set emptystart
  • Step 6:set folder=Maildir
  • Step 7:set record= +sent
  • Step 8:Save and close the file.

Step 7: Initialize the Mail directory structure

  • Step 1:You can initialize the mail directory structure using the mail command. After initializing the mail directory, you can send the files of your desire.
  • Step 2:Make sure to disable writing to the initial email address using the ~Snorecord option. To do so, run the following command: $ echo init | mail –s init -Snorecord “Linux user name”
  • Step 3:Check the status of your Mail directory using the $ ls –R ~/Maildir command.

Congratulations! You have successfully performed the Postfix mail server configuration in Ubuntu step by step.