I have installed a send only postfix. Postfix works when I send a mail to a full email address. However, if a mail to sent to a user, it adds the FQDN name as the extension instead of just the domain name I have set-up during installation.

For example, when I send a mail from ssh like this:

echo "This will go into the body of the mail." | mail -s "Hello world" root

I want the mail to go to root@example.com.au. But the email is sent to root@host.example.com.au.

I have reviewed my host settings, mailname settings, postfix settings and I have no clue on why it keeps adding the full hostname to it which obviously is getting bounced. Here are my config files:

Postfix main.cf:

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = host.example.com.au
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination =
relayhost =
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only

virtual_alias_maps = hash:/etc/postfix/virtual


mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root


root            admin@example.com.au



/etc/hosts:       localhost
11x.0.0.xxx   host.example.com.au    host



I have reviewed everything and I dont have a clue on why mail send to @host.example.com.au. Can someone help me here please?

I am on debian 8.

EDIT: Just now, I tried adding one more setting to main.cf file: masquerade_domains = $mydomain. Adding this seems to fix the from address to show my domain name instead of hostname but yet, the to address is still having the FQDN name. I am receiving the bounced email "Mail Delivery System" notification on my email address since the origin email is now right after adding the masquerade_domains, but still cant get my head around why the user email is not respecting the same and the to address is still addressed as root@host.example.com.au instead of root@example.com.au.

myhostname = host.example.com.au
mydomain = example.com.au
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $mydomain
masquerade_domains = $mydomain
mydestination =
relayhost =
mynetworks = [::ffff:]/104 [::1]/128
  • If you haven't try it already: put root: admin@example.com.auin /etc/aliases file, run newaliases and see. – Diamant Jan 8 '16 at 13:32

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

root: admin@example.com.au

I have tested it and it works.

  • Hi bangal thank you for your answer. Unfortunately that did not work. I did try that before although I forgot to add that edit to my question and I tried that once again now by adding email address for root in aliases and rebuilt using newaliases. It did not make any difference and the email to root user is still sent to root@hostname – Neel Jan 8 '16 at 13:45
  • I also tried adding the email to virtual_alias_maps and that didnt help neither. – Neel Jan 8 '16 at 13:47
  • Well, here is another alternative using mail.rc file. Set an alias there like: alias root admin@example.com.au in /etc/mail.rc file and see what happens. – Diamant Jan 8 '16 at 14:17
  • Hi bangal, I tried it but it didint work. I did not have /etc/mail.rc file so I created a new one and added the alias there. Still same results. Do you think it might be due to using postfix or mail in Debian 8? I dont know, I have the exact same set-up on Debian 7 and it works fine on that server. Still no clue here.. – Neel Jan 8 '16 at 17:06
  • @Neel, ok, then create an alias like this: @host.example.com.au @example.com.au in the /etc/postfix/virtual file, run postmap and then restart postfix and see. – Diamant Jan 8 '16 at 20:51

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: root@example.com.au

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!

  • Thanks and also you need to add masquerade_domains = $mydomain. This was needed to get it working for my setup. – Ricky Boyce Jun 14 '17 at 15:14

Can you give a shot and try to add the example.com.au to your hosts file? Reference: http://www.tldp.org/LDP/solrhe/Securing-Optimizing-Linux-RH-Edition-v1.3/chap9sec95.html

  • Hi Lucas, but I already have added example.com.au to my hosts file similar to the referenced link. Host file code in included in my question. If you mean, I try adding 11x.0.0.xxx example.com.au host instead of 11x.0.0.xxx host.example.com.au host then isint that wrong as the hosts should be in this order: ip FQDN Host? Or did I misunderstand what you meant? – Neel Jan 8 '16 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.