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 [email protected]
. But the email is sent to [email protected]
.
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_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
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 = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
virtual_alias_maps = hash:/etc/postfix/virtual
Aliases:
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
/etc/postfix/virtual:
root [email protected]
/etc/mailname:
example.com.au
/etc/hosts:
127.0.0.1 localhost
11x.0.0.xxx host.example.com.au host
/etc/hostname
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 [email protected]
instead of [email protected]
.
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 = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
You need to put an alias for
root
in the/etc/aliases
file like below, and then runnewaliases
and it should work.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
inmain.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
andlocalhost
asmydestination
inmain.cf
like this:2) aliases:
Next, I added the email address for root user in
/etc/aliases
like this:3) newaliases:
Lastly, I rebuild aliases and reloaded postfix
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 toaliases
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
asmyorigin
in the first place and kept addinghostname
suffix to user is still a mystery. However, the above method seem to be the solution when postfix is adamant to addhostname
to all mails addressed to the user directly.Hope this helps!
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