In this tutorial, we will show you how to install Postfix on Ubuntu 20.04 LTS. For those of you who didn’t know, Postfix is a free and open-source MTA (Mail Transfer Agent) used for routing or delivering emails on a Linux system. By the default configuration it permits local mailing, however in itself it is very useful on a machine used by many customers, or even if there may be no such visitors, many services dump their reviews and messages into e-mails, which is introduced to the root consumer locally, so the sysadmin might be noticed on any activities when he/she logs in and switches to root user.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of the Postfix mail on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
Install Postfix on Ubuntu 20.04 LTS Focal Fossa
Step 1. First, make sure that all your system packages are up-to-date by running the following
apt commands in the terminal.
sudo apt update sudo apt upgrade
Step 2. Installing Postfix on Ubuntu 20.04.
Now we proceed with the installation of Postfix by running the following command:
sudo apt install postfix sasl2-bin
Now you will be prompted to choose the type of your Mail Server Configuration. Select proceed to select [No Configuration] from that list and press the Enter key as highlighted in the following image:
+------+ Postfix Configuration +-------+ | General type of mail configuration: | | | | No configuration | | Internet Site | | Internet with smarthost | | Satellite system | | Local only | | | | | | <Ok> <Cancel> | | | +--------------------------------------+
Step 3. Configuring Postfix.
Once successfully installed, Now we edit the Postfix configuration file:
cp /usr/share/postfix/main.cf.dist /etc/postfix/main.cf nano /etc/postfix/main.cf
Add the following lines:
mail_owner = postfix
myhostname = mail.idroot.us
mydomain = idroot.us
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
local_recipient_maps = unix:passwd.byname $alias_maps
mynetworks_style = subnet
mynetworks = 127.0.0.0/8,10.0.0.0/24
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
sendmail_path = /usr/sbin/postfix
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
inet_protocols = ipv4
# for example, limit an email size to 10Mmessage_size_limit = 10485760# for example, limit mailbox size to 1Gmailbox_size_limit = 1073741824# SMTP-Auth settings smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous smtpd_sasl_local_domain = $myhostname smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, permit_sasl_authenticated, reject
Save the file and close it. To apply the changes, enter the command:
newaliases sudo systemctl restart postfix
Congratulations! You have successfully installed Postfix. Thanks for using this tutorial for installing the Postfix on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official Postfix website.