What should I set in postfix's myhostname / mydestination?

10,692

Solution 1

$myhostname is by default the same as the systems FQDN. This should be like hostname.example.com. Take a look in the manpages of hostname and associates to configure it correctly for your system. The $myhostname variable is used in many other parameters, such as smtp_helo_name, which should be a valid and correct FQDN. Otherwise your mail may be rejected by many servers, or at least marked as spam (rejecting wrong helos is a nice spam reduction technique btw).

As Craig Watson already said, mydestination is not that important if no mail is delivered there. (But reading mail to the server admin, like webmaster and postmaster, is highly recommended!)

Last thing: Be sure to have this server included in your SPF entry in DNS.

Solution 2

myhostname should be set to the FQDN of the server.

If your server never receives email, then you can safely set mydestination to localhost as the mydestination directive controls the domains which Postfix will attempt to deliver locally.

See Postfix documentation: http://www.postfix.org/postconf.5.html#mydestination

Share:
10,692

Related videos on Youtube

Howard
Author by

Howard

Updated on September 18, 2022

Comments

  • Howard
    Howard almost 2 years

    I am using Ubuntu, on a web server need to send out email (via sendgrid), this server never receive any external email, and I've the following hostname settings

    /etc/hostname = example
    /etc/hosts = www.example.com.int example (the fqdn has no entry in DNS server)
    

    The web server will be accessed behind a load balancer (which DNS set as www.example.com)

    Now, for main.cf, which setting is preferred?

    myhostname = www.example.com.int
    mydestination = www.example.com.int, example.com.int, localhost
    

    OR

    myhostname = www.example.com
    mydestination = www.example.com, example.com, localhost
    
  • Howard
    Howard almost 10 years
    So should I set a public FQDN (in DNS server) for my web server instead of using private/internal FQDN? e.g. server1.example.com? And probably set a reverse DNS record from the IP to hostname?
  • sebix
    sebix almost 10 years
    @Howard, yes! Be sure to have resolvable FQDNs, and a PTR record (preferably with the FQDN as result, but it's more important that it exists). Everything other than this setup is mimicking a spammer :)
  • Howard
    Howard almost 10 years
    Actually this is not true, your system such as cron job still need to delivery email for example, for mydestination as least need to include what you set in /etc/mailname, for example