Postfix sends to FQDN Hostname instead of Domain Name

You need to put an alias for root in the /etc/aliases file like below, and then run newaliases and it should work.

root: [email protected]

I have tested it and it works.


Finally got it working. These are the steps I did to resolve my trouble:

1) mydestination:

Since I had a send only mail server, I left mydestination in main.cf file empty as per the postfix man page. However, doing do ended up having the above behaviour were the local emails are sent with hostname appended which was getting bounced. Therefore I added $hostname and localhost as mydestination in main.cf like this:

mydestination = $myhostname, localhost

2) aliases:

Next, I added the email address for root user in /etc/aliases like this:

root: [email protected]

3) newaliases:

Lastly, I rebuild aliases and reloaded postfix

sudo newaliases
sudo service postfix reload

What Fixed it:

Since aliases are used for local delivery only and I dont have local delivery (meaning $mydestination is empty), having the root email address in aliases didn't make any difference. Now after adding the $hostname to my destination, any emails sent to a user which was getting appended with $hostname is getting picked up as $mydestination that is then referring to aliases which ultimately tells postfix to deliver that email to another email address.

What I still dont understand is why the postfix was ignoring the $domainname as myorigin in the first place and kept adding hostname suffix to user is still a mystery. However, the above method seem to be the solution when postfix is adamant to add hostname to all mails addressed to the user directly.

Hope this helps!