How to Reinstall Postfix on Ubuntu and Trigger the Configuration Wizard Again


3 views

When you remove Postfix completely using apt-get remove and manually delete the /etc/postfix directory, Ubuntu's package system loses track of the previous configuration state. This is why the interactive configuration wizard doesn't appear during subsequent installations.

To get the configuration wizard back, you need to perform a purge installation:

sudo apt-get purge postfix
sudo rm -rf /etc/postfix
sudo apt-get update
sudo apt-get install postfix

If you've already installed Postfix without getting the wizard, you can trigger it manually:

sudo dpkg-reconfigure postfix

This will launch the familiar configuration dialog where you can select:

  • Internet Site
  • Satellite System
  • Local Only

After configuration, check the status:

sudo postfix status
sudo systemctl status postfix

If you prefer manual configuration, edit the main configuration file:

sudo nano /etc/postfix/main.cf

Here's a basic configuration for an internet site:

myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
relayhost =
mynetworks = 127.0.0.0/8
home_mailbox = Maildir/

If you're still not getting the configuration wizard:

sudo apt-get install debconf-utils
echo "postfix postfix/main_mailer_type select Internet Site" | sudo debconf-set-selections

When you first install Postfix on Ubuntu using apt-get, the package manager typically launches an interactive configuration wizard. This is controlled by the debconf system which remembers your previous choices - even after uninstallation.

Your removal process did two things:
sudo apt-get remove postfix uninstalled the package but kept configuration files
rm -rf /etc/postfix deleted the configs but didn't reset debconf settings

Here's how to properly reset everything:

# Purge all postfix packages and configurations
sudo apt-get purge postfix postfix-*

# Reset debconf selections
echo "postfix postfix/main_mailer_type select Internet Site" | sudo debconf-set-selections
echo "postfix postfix/mailname string $(hostname -f)" | sudo debconf-set-selections

# Reinstall fresh
sudo apt-get install postfix

If you prefer to skip the wizard entirely, configure manually:

# Install non-interactively
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y postfix

# Then configure main.cf manually
sudo nano /etc/postfix/main.cf

Check if Postfix is running properly:

sudo systemctl status postfix
sudo postconf -n

Basic Internet Site configuration in /etc/postfix/main.cf:

myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_protocols = all