LinuxCommandLibrary

postfix

Manage and configure the Postfix mail server

TLDR

Check the configuration

$ sudo postfix check
copy

Check the status of the Postfix daemon
$ sudo postfix status
copy

Start Postfix
$ sudo postfix start
copy

Gracefully stop Postfix
$ sudo postfix stop
copy

Flush the mail queue
$ sudo postfix flush
copy

Reload the configuration files
$ sudo postfix reload
copy

SYNOPSIS

postfix [-v] [-c config_dir] [-l ledger_file] [-n count] [-t timeout] [-z queue_id] command [argument ...]
Common commands include: start, stop, reload, flush, check, status, upgrade.

PARAMETERS

-c config_dir
    Specify the configuration directory instead of the compiled-in default. This allows running multiple Postfix instances or testing different configurations.

-v
    Enable verbose logging for the executed command, showing more details about its operations, often used for debugging.

-l ledger_file
    Used with set-uid-back and set-gid-back subcommands to specify the ledger file for ownership restoration after a system recovery.

-n count
    Used with the flush subcommand to limit the number of messages flushed from the mail queue in a single operation.

-t timeout
    Used with the flush subcommand to specify a timeout in seconds for the queue flush operation, preventing indefinite waits.

-z queue_id
    Used with the flush subcommand to specify a particular queue ID to flush, targeting a specific message for delivery.

DESCRIPTION

Postfix is the primary command-line interface for administering the Postfix Mail Transfer Agent (MTA), a robust and widely used open-source mail server. It provides system administrators with a centralized tool to control all aspects of the Postfix system. Through various subcommands, postfix enables actions such as starting and stopping the mail services, reloading configuration changes without interruption, managing and inspecting the mail queues, checking for configuration errors, and performing system upgrades. It effectively acts as a dispatcher, invoking specialized Postfix helper utilities (like postconf, postsuper, and postqueue) behind the scenes. This streamlines the daily management of email services, making postfix an indispensable command for maintaining mail flow, troubleshooting issues, and ensuring the secure and efficient operation of the Postfix MTA on Linux and Unix-like systems.

CAVEATS

Most postfix commands require root privileges to execute successfully, as they interact with system services and sensitive configuration files. Incorrect use or misconfiguration can lead to mail service disruptions, security vulnerabilities, or data loss. Always back up configuration files before making significant changes and test configuration changes in a non-production environment if possible.

COMMON SUBCOMMANDS

The postfix command acts as a front-end to many specialized Postfix utilities. Key subcommands, each executing a specific Postfix management task, include:

  • start: Initiates the Postfix mail system daemons.
  • stop: Halts all running Postfix mail system daemons.
  • reload: Instructs the Postfix master daemon to reload its configuration files (e.g., main.cf, master.cf) without service interruption, applying changes live.
  • flush: Immediately attempts to deliver all pending messages in the mail queue.
  • check: Verifies the Postfix configuration for syntax errors and common issues, providing warnings or errors if problems are found.
  • status: Displays the running status of Postfix daemons and potentially the mail queue count.
  • upgrade: Performs an upgrade of the Postfix system to a newer version's configuration standards, adapting old configuration files to new formats.
  • set-uid-back, set-gid-back: Restore proper ownership (user ID and group ID respectively) to Postfix files and directories, often useful after system recovery or migration to ensure correct permissions.

HISTORY

Postfix was initially developed by Wietse Venema at IBM starting in 1997, as a more secure, reliable, and performant alternative to the widely used Sendmail MTA. Its first public release was in 1998, under the name 'V8'. It quickly gained popularity due to its modular design, robust security features, and relatively simpler configuration compared to its predecessors, becoming a dominant MTA in the Linux and Unix world.

SEE ALSO

postconf(1), postsuper(1), postqueue(1), mailq(1), master(8), main.cf(5), access(5)

Copied to clipboard