Setting myhostname and Mydomain in postfix for mutiple domains
myhostname
and mydomain
are just default values used for various purposes. For example,
- message-IDs are of the form something@myhostname,
- during the SMTP HELO/EHLO phase, the server identifies itself as myhostname,
- when a mail is sent to someone@somewhereWithoutADot, mydomain is added automatically,
- etc.
For a detailed list, man 5 postconf
and search for myhostname
and mydomain
.
Thus, if you have a main domain that your mail server is responsible for, choose that. If you don't, choose any of the domains. Note that your system already has a main hostname: check the output of the commands hostname
and hostname --fqdn
.
It does not matter that the A record of domain1.tld
points somewhere else. The important thing is that myhostname resolves to the IP address of your mail server; otherwise, other mail servers will eye you with suspicion and spam filters are more likely to dislike your mails.
For mydomain I would use the following rule of thumb: Check the output of the command hostname
. If a mail is sent to someone@outputOfHostname, what domain should be appended to make it reach your system?
Related videos on Youtube
![samayo](https://i.stack.imgur.com/2Jqez.jpg?s=256&g=1)
samayo
Fullstack Developer living in CH Github Projects: A PHP secure image uploader Country data to JSON Fast PHP blogging app for developers
Updated on September 18, 2022Comments
-
samayo almost 2 years
I have 5 domain names currently pointing to my email server, which is running CentOS 6.5 with Postfix, Dovecot installed. Although I am now only able to receive emails but not send (for reasons I can't understand) I am having trouble configuring this part of the
main.cf
as there seems to be a place for only one domain name and host to be specified.# The default_privs parameter specifies the default rights used by # the local delivery agent for delivery to external file or command. # These rights are used in the absence of a recipient user context. # DO NOT SPECIFY A PRIVILEGED USER OR THE POSTFIX OWNER. # #default_privs = nobody # INTERNET HOST AND DOMAIN NAMES # # The myhostname parameter specifies the internet hostname of this # mail system. The default is to use the fully-qualified domain name # from gethostname(). $myhostname is used as a default value for many # other configuration parameters. # myhostname = mail.domain1.tld #myhostname = virtual.domain.tld # The mydomain parameter specifies the local internet domain name. # The default is to use $myhostname minus the first component. # $mydomain is used as a default value for many other configuration # parameters. # mydomain = mail.domain1.tld
Here I am forced to mention
mail.domain1.tld
while in fact, I have 4 other domains. And the second confusing thing is that, sincedomain.tld
is pointing to another web host VPS, I am only pointingmail.domain1.tld
to this email host. So, I am suremydomain = domain1.tld
would make no sense.So, I guess my point is, what value do I give to this attribute, it I am hosting emails for more than one domain?
-
GeneBean about 10 yearsmydomain isn't mail.domain1.tld but rather domain1.tld. What is your mydestination set to?
-
GeneBean about 10 yearsThat makes no difference. You are not setting an A record, you are saying where your mail is coming from... aka mydomain matches whats after the @
-
samayo about 10 years@GeneBean Ok, forgive the noobness in me talking, but let me get it clear this time. You are saying, even if I am hosting an email for 100+ domains, it will be enough to mention just one of them as
mydomain =
&myhostname =
?? And in this case, I have no hostname. I only have domain names. The hosting for these emails is done in a VPS that is only identified by its IP. -
GeneBean about 10 yearsI really think you need to pause and read library.linode.com/mailserver as it will give you the information needed to do this right. You can also find lots of hints that my help at postfix.org/documentation.html Reading that Linode guide will be faster & more productive than working through the multiple Q's you've posted here.
-
-
samayo about 10 yearsOk, I found something surprising.
hostname --fqdn
gives memyname.cloud.vps_provider_name.com
I guess it is using assigned name my provider gave me. Second thing is that, I don't have a domain responsible for that server, because all mydomains point to my web host (another VPS) so, this has nothing except the ID. But I don't understand what you meantThe important thing is that myhostname resolves to the IP address of your mail server
can you clarify it a bit pls ? thanks @Heinzi -
Heinzi about 10 yearsDo you understand how DNS works? If yes, make sure that the
A
record of myhostname points to the IP address of your server (i.e., if you typehost mail.domain1.tld
you should get your own IP address). If not, you might want to read up on that... it's among those things that you "should know" when you are running your own mail server. -
samayo about 10 years
-
samayo about 10 years@Heinze You can see the images in my comment, in the link. I took screenshots for both
-
Heinzi about 10 years@ANW: Ah, ok, sorry, didn't see that. So you are saying that
host mail.s....com
does not return8...
? -
samayo about 10 years
ping mail.s...com
returns the IP. But,host
returns-bash: host: command not found
-
Heinzi about 10 yearsAh, ok, that is fine then.
-
samayo about 10 yearsWell, what could possibly be the problem? I have followed this tutorial word for word after fresh install. I have even disabled SELINUX, and stopped Iptables. Maybe the mistake is from their side?
-
Heinzi about 10 yearsWhat problem are we talking about? I thought you just wanted advice on what to use for myhostname and mydomain...
-
samayo about 10 yearsAh, I got it confused with other question. I thought that might have been the problem as to why I could not receive any emails but after it just now, it's all the same