I'm trying to set up postfix for the first time. Reading the basic configuration docs, right off the bat I'm faced with two settings that I cannot understand - mydomain
and myhostname
. I've got the simplest possible situation - a single server for a single domain. Let's call it example.com
. My server serves the webpages for http://anything.example.com
and I'd like it to receive email for [email protected]
as well. (Sending too, but that will be only for authorized users; I'll come to that later)
So, in this case, what's the difference between mydomain
and myhostname
? Or should they both be simply set to example.com
?
Also of note might be that my DNS provider (I don't host it myself) for some reason didn't allow me to put example.com
in my MX
record. That seemed to be more of a quirk of their system however. I have mail.example.com
set there, but *.example.com
maps to my IP anyway (in A
records), so that shouldn't really matter, right?
myhostname is the fully qualified domain name. mydomain, is the domain you are using for your email.
From the docs
The crucial part of the documentation for both is the following, as it tells us how they are used.
To know what you should have in both, consult the output of
postconf
:For receiving mail for
example.com
you only need to have it inmydestination
(orvirtual_alias_domains
etc.) which by default only has$myhostname
andlocalhost.$mydomain
. Notice that becausemydestination
can be configured to include plainexample.com
(or the variable$mydomain
containing it), there's no need to have$myhostname = example.com
. The final destination addresses are not directly based on these variables i.e. it doesn't limit the domains you can accept mail for.On the other hand,
$myhostname
is used insmtpd_banner
andsmtp_helo_name
. As RFC 5321, 4.1.1.1 explains, this should be the fully-qualified domain name (FQDN) of the SMTP client (i.e. your server). Some receiving MTAs may validate that theHELO
hostname matches thePTR
record for the IP address, a mismatch causing additional spam score or in worst case even rejection. Therefore, it's recommended to match$myhostname
with whatever there is in thePTR
record, and check that thePTR
has a correspondingA
record.Additionally, if you wish to receive mail for
[email protected]
, the*.example.com. A
DNS record alone isn't enough (despite it gets used if there's noMX
records), but you need to have it listed in yourmydestination
, too.myhostname is the hostname of the postfix server installed. domain name is the SMTP server domain configured.