Home -> Step by step guides -> Setting up postfix on debian
This is usually done using the following command in a terminal or command-line interface:
ssh username@your_server_ip
Step 2: Updating System Packages
Before anything else, we need to make sure we have the latest updates. Enter the following command:
sudo apt update && sudo apt upgrade
Step 3: Installing Postfix
To install Postfix, run the following command:
sudo apt install postfix
During the installation, a configuration window may appear. Select ‘Internet Site’, then provide your fully qualified domain name (FQDN) or alias.
Step 4: Configuring Postfix’s Main Configuration File
We need to modify Postfix’s main configuration file. Let’s first backup the existing one:
sudo cp /etc/postfix/main.cf /etc/postfix/main.cf.backup
Now, open it with a text editor like nano:
sudo nano /etc/postfix/main.cf
Step 5: Setting Up General Settings
In the configuration file, find and modify these parameters, replacing ‘your_domain.com’ with your domain:
myhostname = mail.your_domain.com
mydomain = your_domain.com
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost
inet_interfaces = all
Step 6: Setting Up Mailbox
Under your general settings, add these lines to add mailbox settings:
home_mailbox = Maildir/
mailbox_size_limit = 0
recipient_delimiter = +
Step 7: Configuring SMTP
Add or modify these lines to configure SMTP:
smtpd_banner = $myhostname ESMTP
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks,permit_sasl_authenticated,defer_unauthenticated_sender
After making these changes, save and close the file (with nano, you can do this with ‘Ctrl + X’, then ‘Y’ then hitting ‘Enter’).
Step 8: Restarting Postfix
Restart Postfix for the changes to take effect:
sudo systemctl restart postfix
Step 9: Checking Postfix Status
Check the status of your Postfix service using:
sudo systemctl status postfix
If everything is set up correctly, your output should show that the Postfix mail server is running.
Step 10: Testing the Mail Server
Send a test email using the mail command:
echo "This is a test mail" | mail -s "Test Mail Subject" your-email@example.com