Basic settings in the Postfix file

After you have installed Postfix, you can work with settings in the file to further configure Postfix.

Note: This article assumes that you are using a single domain for your email needs.

Modular nature of Postfix

One of the key aspects of Postfix is that it is designed to be a modular package. The base installation itself is fairly small, and the vast majority of the "usual" mail administration, such as anti-spam and anti-virus, is actually conducted by third-party packages like SpamAssassin.

You can begin to see the modular nature of Postfix when you look at the file. Many settings refer to other files on the server. This setup can seem slightly confusing at first, and your initial reaction might be to hard code the data rather than reference another file with a single word in it. However, we recommend retaining the modularity of Postfix and editing multiple files for what might seem like simple settings. Such modularity will be useful when you start adding multiple domains, users, and aliases to your setup.

The file

To see the file, issue the following command:

sudo nano /etc/postfix/

The file consists of basically three sections. The first section includes several settings such as the smtpd_banner and biff parameters. The second section has settings for TLS parameters.

This article focuses on the last section, which looks as follows on the democloud server:

myhostname =

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

myorigin = /etc/mailname
mydestination =,, , localhost

relayhost =
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

Note that some of the settings already have the host name from the base Postfix installation.

Although some of the settings might be self-explanatory, the following sections describe them so that you can get a better understanding of Postfix and what you can do with it.


The myhostname value was set during the Postfix installation when you entered the domain name that you want to use. This name also matches the cloud server host name.


Aliases provide a method for delivering mail to different users without having to set up dozens of different accounts. The default settings in the reference another file:

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

Open that file, as follows:

sudo nano /etc/aliases

The file shows a list of names followed by root. Mail delivered to the first name is actually delivered to the second name. You do not need to set up the postmaster, news, webmaster, abuse, and other users for Postfix because mail delivered to those names is sent to root.

Using the same syntax, you can have all mail for root delivered to the admin user by adding the following line (demo is the main admin user for the democloud server):

root: demo

As a result, the delivery destination would change as follows:

  1. Mail sent to mailer-daemon is sent to postmaster.
  2. Mail to postmaster is sent to root.
  3. Mail sent to root is sent to the main admin user demo.

You can adjust the aliases as you see fit, but instead of changing all the root users in the file, it is easier to add the one line as shown. Adding that line also makes future migration and administration easier.

After you change the aliases file, you must refresh the aliases database for any changes to occur. Use the following command:

sudo newaliases


Internal emails from packages such as cron jobs do not supply full mail credentials; they use the myorigin setting instead. As such, you need to set this parameter to the main host name of the server.

By default, the setting refers to the /etc/mailname file. To look at the contents, run the following command:

cat /etc/mailname

Example output for the democloud server is as follows:

However, you can also set myorigin by using $mydomain in the file, as follows:

myorigin = $mydomain

Although you haven't specifically set the $mydomain variable, Postfix gets the information from the myhostname setting, parsing the host name to gain the main domain name.

Setting the myorigin parameter this way allows for easier administration at a later date because only one setting (myhostname) needs to change. All the other parameters take the change from that.


Although you have not yet set the server to receive mail (that is covered in the next article), the mydestination parameter defines the domains from which the server will accept mail.

The default looks as follows:

mydestination =,, , localhost

The default is adequate when you are setting up mail for a single domain. However, like with the myorigin setting, you can reduce future administration by using the $mydomain variable as follows:

mydestination = $mydomain, localhost.$mydomain, localhost


For the setup in this series of articles, you do not need this setting. You can leave it blank.


The mynetworks parameter defines the network to use. The default value includes IPv6 settings, which you can remove. The remaining value looks as follows:

mynetworks =

The rest

You can use the default values for the remaining settings. They are relevant for more complex configurations.

Final settings

After the preceding changes, the last section in the example file looks as follows:

myhostname =

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

myorigin = $mydomain
mydestination = $mydomain, localhost.$mydomain, localhost

relayhost =
mynetworks =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

Test the settings

As with all packages, after you have made any changes to the configuration, you must restart, as follows:

sudo /etc/init.d/postfix restart

After Postfix is restarted, you can conduct a quick test by sending an email to a working email address, as shown in the following example. (For instructions, see the test section in Install Postfix.)

Subject: test

You should receive an email from the correct user and the correct domain. Check the headers to verify that they are correct.


Configuring Postfix can be a daunting task. This introduction helps with the basics and shows how using variables instead of hard coding domain names can save time and effort in any future administration.

Where to go from here

Creating DNS records and receiving emails via Postfix

© 2015 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER