Skip to content
Home ยป Installing the Postfix Server

Installing the Postfix Server

Installing the Postfix Mail Server in Linux


1. Introduction

Postfix is a widely used Mail Transfer Agent (MTA) in Linux that is responsible for sending and routing emails using the SMTP protocol.

๐Ÿ‘‰ It is preferred because it is:

  • Fast
  • Secure
  • Easy to configure
  • Reliable for server environments

2. Role of Postfix in Email System

Postfix works as an SMTP server:

Mail Client
     โ†“ SMTP
Postfix Server
     โ†“
Internet
     โ†“
Recipient Mail Server

๐Ÿ“Œ It handles sending and forwarding emails.


3. Requirements Before Installation

  • Linux system (Ubuntu / CentOS)
  • Root or sudo access
  • Static IP (recommended)
  • Proper hostname (e.g., mail.example.com)

4. Installing Postfix


4.1 On Ubuntu / Debian

sudo apt update
sudo apt install postfix

During installation:

  • Choose: Internet Site
  • Enter mail name (e.g., example.com)

4.2 On RHEL / CentOS

sudo yum install postfix

5. Main Configuration File

/etc/postfix/main.cf

6. Basic Configuration

Edit file:

sudo vi /etc/postfix/main.cf

Important Parameters

myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain

inet_interfaces = all
inet_protocols = ipv4

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

home_mailbox = Maildir/

7. Starting and Managing Postfix

Start Service

sudo systemctl start postfix

Enable at Boot

sudo systemctl enable postfix

Check Status

sudo systemctl status postfix

Restart Service

sudo systemctl restart postfix

8. Configuring Firewall

Allow SMTP traffic:

sudo ufw allow 25

For CentOS:

firewall-cmd --permanent --add-service=smtp
firewall-cmd --reload

9. Testing Postfix Installation

Send Test Mail

echo "Test Mail" | mail -s "Test Subject" user@localhost

Check Mail Logs

tail -f /var/log/mail.log

10. Mail Storage Location

  • Mail stored in:
/home/user/Maildir/

11. Important Postfix Commands

CommandPurpose
postfix startStart service
postfix stopStop service
postfix reloadReload config
mailqView mail queue
postqueue -fFlush queue

12. Real-World Example

  • Organization email system:
    • Postfix handles outgoing mail
    • Dovecot handles incoming mail
    • DNS MX record points to mail server

13. Advantages of Postfix

  • Secure by design
  • High performance
  • Easy configuration
  • Scalable for enterprise use

14. Common Issues

  • Port 25 blocked
  • Incorrect hostname
  • DNS MX record missing
  • Firewall blocking SMTP

15. Conclusion

Postfix is a powerful and efficient mail server used in Linux systems. Proper installation and configuration allow reliable email transmission using SMTP, making it essential for server and network administration.