What are the Configuration Files for Postfix

Postfix is a powerful but easy-to-configure mail server. It is the default mail server in CentOS/RHEL 7. Postfix is provided by the postfix RPM package. It is a modular program made up of several cooperating programs. Its components are controlled by the master process.

The main configuration file of the postfix mail server is /etc/postfix/main.cf.

Important Posfix Configuration Settings

Below are some important Postfix configuration settings available in CentOS/RHEL 7.

inet_interfaces Controls which network interfaces Postfix listens on for incoming and outgoing messages. If set to loopback-only, Postfix listens only on and ::1. If set to all, Postfix listens on all network interfaces. One or more host names and IP addresses, separated by white space, can be listed. Default:inet_interfaces = localhost
myorigin Rewrite locally posted email to appear to come from this domain. This helps ensure responses return to the correct domain the mail server is responsible for. Default:myorigin = $myhostname
relayhost Forward all messages to the mail server specified that are supposed to be sent to foreign mail addresses. Square brackets around the host name suppress the MX record lookup. Default:relayhost =
mydestination Configure which domains the mail server is an end point for. Email addressed to these domains are delivered into local mailboxes. Default:mydestination = $myhostname, localhost. $mydomain, localhost
local_transport Determine how email addressed to $mydestination should be delivered. By default, set to local:$myhostname, which uses the local mail delivery agent to deliver incoming mail to the local message store in /var/spool/mail. Set this to error: error message, e.g., local_transport = error: local delivery disabled, to disable local delivery completely. Default:local_transport = local:$myhostname
mynetworks Allow relay through this mail server from a comma-separated list of IP addresses and networks in CIDR notation to anywhere, without further authentication. If the mynetworks setting is not explicitly set in /etc/postfix/ main.cf, it will be filled automatically using the setting for mynetworks_style. The default for mynetworks_style is subnet, meaning that all subnets in which the server has an IP address will be added to mynetworks. This is often not a desired situation, especially in situations where the server has an external IP address. It is recommended that a mynetworks setting gets added manually, or mynetworks_style is set to host. Default:mynetworks = [::1]/128

The configuration file /etc/postfix/main.cf can be edited in two ways: by hand using a text editor such as vim, or it can be edited using the postconf utility. The postconf command allows

for querying by individual or all settings, modifying settings, querying defaults, or showing all settings that differ from the built-in defaults:

1. Run the postconf command without any parameter to query all settings from the /etc/ postfix/main.cf configuration file:

# postconf
2bounce_notice_recipient = postmaster
access_map_defer_code = 450
access_map_reject_code = 554
address_verify_cache_cleanup_interval = 12h
address_verify_default_transport = $default_transport

2. Query a particular set of options by listing them after the postconf command, separated by white space. Run the following to list the inet_interfaces and myorigin options with their corresponding values:

# postconf inet_interfaces  myorigin
inet_interfaces = loopback-only
myorigin = $myhostname

3. Run the following to add new or change existing options in the /etc/postfix/main.cf configuration file: postconf -e ‘setting = value’ If there was already a setting by that name in the configuration file, it will be updated to the new value; otherwise, it will be added to the bottom of the configuration file.

Run the following to change the myorigin setting to rewrite the domain part of the FROM: Email address to example.com:

# postconf -e 'myorigin = example.com'

Note: The postfix service requires a reload or restart after the changes have been made to /etc/postfix/main.cf.


When troubleshooting email, a log of all mail-related operations is kept in the systemd journal and /var/log/maillog, which includes information of any mail server-related actions. The postqueue -p command displays a list of any outgoing mail messages that have been queued. To attempt to deliver all queued messages again immediately, run the postqueue -f command; otherwise, Postfix will attempt to resend them about once an hour until they are accepted or expire.