Setting myhostname and Mydomain in postfix for mutiple domains

10,070

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?

Share:
10,070

Related videos on Youtube

samayo
Author by

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, 2022

Comments

  • samayo
    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, since domain.tld is pointing to another web host VPS, I am only pointing mail.domain1.tld to this email host. So, I am sure mydomain = 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
      GeneBean about 10 years
      mydomain isn't mail.domain1.tld but rather domain1.tld. What is your mydestination set to?
    • GeneBean
      GeneBean about 10 years
      That 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
      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
      GeneBean about 10 years
      I 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
    samayo about 10 years
    Ok, I found something surprising. hostname --fqdn gives me myname.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 meant The important thing is that myhostname resolves to the IP address of your mail server can you clarify it a bit pls ? thanks @Heinzi
  • Heinzi
    Heinzi about 10 years
    Do 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 type host 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
    samayo about 10 years
    I am not getting my IP. Maybe you are right, but as far as I read on the subject, I understood enough to set up A and MX record A RECORD AND MX RECORD I don't see anything wrong with those.
  • samayo
    samayo about 10 years
    @Heinze You can see the images in my comment, in the link. I took screenshots for both
  • Heinzi
    Heinzi about 10 years
    @ANW: Ah, ok, sorry, didn't see that. So you are saying that host mail.s....com does not return 8...?
  • samayo
    samayo about 10 years
    ping mail.s...com returns the IP. But, host returns -bash: host: command not found
  • Heinzi
    Heinzi about 10 years
    Ah, ok, that is fine then.
  • samayo
    samayo about 10 years
    Well, 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
    Heinzi about 10 years
    What problem are we talking about? I thought you just wanted advice on what to use for myhostname and mydomain...
  • samayo
    samayo about 10 years
    Ah, 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