Postfix is increasingly overtaking Sendmail as the MTA of choice on many Linux distributions.
In this solution, we present the simplest of all configurations which enhances Postfix capabilities from simply handling mail for the local host to handling mail for an entire fully qualified domain name (FQDN).
- A registered fully qualified domain name (FDQN)
- At least one MX record added to DNS for above FQDN which points to destination host
- Postfix installed and handling local mail for the destination host
Postfix parameters can be changed from the command line by way of the postconf utility:
[email@example.com ~]$ sudo postconf -e myhostname=mail.example.com
Spaces around the '=' sign are optional. Do not use quotes as these will be interpreted by Postfix as part of the literal.
Our preference is to back up the default main.cf for reference and edit a clean main.cf directly with a preferred text editor (we consider Emacs hands down still the best choice when files must be viewed or edited regardless of whether or not X Server is running).
Changes to main.cf will not go into effect until Postfix is reloaded:
[firstname.lastname@example.org ~]$ sudo postfix reload
The most important configuration changes to be made to main.cf before starting Postfix for the first time involve the identity of your MTA. The affected parameters in main.cf are myhostname, mydomain, myorigin and mydesitnation.
The value of myhostname should be a fully qualified domain name (FQDN). It is assumed here that one will want to receive mail from the Internet and that an MX for the domain has been created (or will be created before Postfix is started). If the FQDN is not set on the Postfix host, do so from the command line:
[email@example.com ~]$ sudo hostnamectl set-hostname server.example.com
Postfix will assign a default value of [domain].[tld] for mydomain, where domain and tld are the name of the domain and the top level domain parts of myhostname respectively. In our example, mydomain would default to
Postfix uses the value of myhostname by default. This means in our example recipients would receive emails addressed from
firstname.lastname@example.org. If the preference is to omit the server name from the address (
email@example.com), set myorigin to $mydomain.
myorigin = $mydomain
Postfix will accept mail for $myhostname and localhost.$mydomain by default. Add $mydomain if you want Postfix to accept mail for the entire domain (instead of a single host on the domain).
mydestination = $myhostname, localhost.$mydomain, $mydomain
Validation of your configuration should report no errors (these would appear both on the screen and in the log files after issuing the command below).
[firstname.lastname@example.org ~]$ sudo postfix check
Dent, Kyle D. Postfix: The Definitive Guide. O’Reilly Media Inc. 2004.
Sobell, M.G.2014 A Practical Guide to Fedora and Red Hat Enterprise Linux. Prentice Hall.