Postfix vs Sendmail: Key Differences and Compatibility Explained for Linux Mail Servers


2 views

When working with mail servers on Linux systems, it's crucial to understand that Postfix and Sendmail are distinct MTA (Mail Transfer Agent) implementations. While they serve similar purposes, their architectures and configurations differ significantly.

The mail command you're using is actually part of the mailutils package (or similar packages like bsd-mailx). This command interfaces with whatever MTA is configured as the default sendmail-compatible program on your system. In your case with Postfix installed, it's likely using Postfix's sendmail-compatible interface.

# This command works with both Postfix and Sendmail
mail -s "Test Subject" user@example.com <<< "Message body"

Sendmail refers to two things in the Linux mail ecosystem:

  • The original Sendmail program: A specific MTA implementation with its own configuration syntax
  • Sendmail compatibility interface: A standard API that many programs use to send mail

Postfix includes a sendmail-compatible program (usually at /usr/sbin/sendmail) that makes it work with applications expecting the traditional Sendmail interface. This is why your mail command works seamlessly.

# Check which sendmail implementation you're using
$ ls -l /usr/sbin/sendmail
lrwxrwxrwx 1 root root 26 Mar 15 09:00 /usr/sbin/sendmail -> /etc/alternatives/sendmail

When software claims to be "Sendmail-ready," it typically means it can work with any MTA that provides a sendmail-compatible interface, including:

  • Postfix
  • Exim
  • Qmail (with compatibility patches)
  • Actual Sendmail

While the command-line interface might be similar, the configuration files differ substantially:

# Postfix main configuration file
/etc/postfix/main.cf

# Sendmail main configuration file
/etc/mail/sendmail.cf

Most web applications use PHP's mail function, which relies on the sendmail interface:

// This works with both Postfix and Sendmail
mail('recipient@example.com', 'Subject', 'Message');

The PHP configuration typically points to the sendmail path:

; php.ini configuration
sendmail_path = /usr/sbin/sendmail -t -i

Postfix was designed as a more secure and performant alternative to Sendmail. Some key differences:

  • Postfix uses multiple daemons with limited privileges
  • Sendmail traditionally used a single monolithic daemon
  • Postfix configuration is generally considered more straightforward

If you need to switch between MTAs, the sendmail compatibility layer makes it relatively painless for most applications. However, system-level configurations will need updating:

# To switch from Sendmail to Postfix on Debian/Ubuntu:
sudo apt remove sendmail
sudo apt install postfix
sudo dpkg-reconfigure postfix

Postfix and Sendmail are both Mail Transfer Agents (MTAs), but they are distinct software implementations with different architectures:

  • Sendmail: The original UNIX MTA (first released in 1983) with monolithic architecture
  • Postfix: A modern alternative (released 1998) designed with security and modularity in mind

When you execute:

mail -s "Subject" address@example.com

This uses the /usr/bin/mail command (part of mailutils/mailx packages), which typically interfaces with the local MTA through:

/usr/sbin/sendmail

Postfix installs a Sendmail-compatible interface at this path for backward compatibility. To verify which MTA is processing your mail:

readlink -f /usr/sbin/sendmail
# Typical Postfix output: /usr/lib/postfix/sendmail

The term "Sendmail" has dual meanings:

Context Meaning
Software The original Sendmail MTA package
Protocol The SMTP submission interface (sendmail binary API)

When software claims to be "Sendmail-ready", it typically means:

  1. It expects to find a /usr/sbin/sendmail compatible binary
  2. It uses the standard command-line flags (-t, -f, -i, etc.)

Postfix maintains this compatibility through its sendmail wrapper. Example PHP mail() function configuration:

; php.ini configuration
[mail function]
sendmail_path = /usr/sbin/sendmail -t -i

Testing MTA type:

telnet localhost 25
220 myhost ESMTP Postfix

Forcing mail queue processing:

# Sendmail
/usr/sbin/sendmail -q

# Postfix
postqueue -f

Configuration file locations:

# Sendmail
/etc/mail/sendmail.cf

# Postfix
/etc/postfix/main.cf

When switching from Sendmail to Postfix:

  • Preserve mail spool directory (/var/spool/mail)
  • Convert aliases (newaliases command works in both)
  • Update firewall rules (Postfix may use different ports)