Postfix Configuration: Determining the Appropriate Settings for myhostname and mydestination

To restrict incoming emails to specific email addresses, I updated the relevant line on my server. This configuration is effective for both internal and external emails. When sending emails locally, I use the recipient’s username without the domain name (since the correct domain is already specified). To send emails via SMTP, I can either use the domain name or the subdomain name. Unfortunately, when a cron job is triggered, the email is sent via SMTP to [email protected] instead of being delivered locally to [email protected] as intended.


I am running Ubuntu on a web server that requires email sending through sendgrid. The server is not designed to receive external emails and has the following hostname configuration.

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

The load balancer, with the DNS set as, will be used to access the web server.

Which setting is preferred for


myhostname =
mydestination =,, localhost


myhostname =
mydestination =,, localhost

Solution 1:

The default value for


is equivalent to the FQDN of the system. To ensure proper configuration, it should be set to something like

. You can refer to the manpages of


and its related components to configure it accurately. The


variable is utilized in several other parameters such as


, which must be a valid and correct FQDN. Failure to do so may result in the rejection of your email by multiple servers or, at the very least, be labeled as spam. Rejecting wrong helos is a useful technique for minimizing spam.

According to Craig Watson,


loses its significance if there is no mail delivery to the location. However, it is strongly advised to check the mail of server administrators such as webmaster and postmaster.

Don’t forget to add this server to your DNS SPF entry.

Solution 2:

The FQDN of the server should be specified as the value for



In case your server doesn’t receive any emails, you can set




without any worries. This is because the


directive is responsible for managing the domains that Postfix will try to deliver locally.

Refer to the Postfix documentation at for more information on the `mydestination` parameter.

Frequently Asked Questions