Postfix发送到FQDN主机名而不是域名

我已经安装了一个只发送后缀。 Postfix在将邮件发送到完整的电子邮件地址时起作用。 但是,如果邮件发送给用户,则会将FQDN名称添加为扩展名,而不仅仅是在安装期间设置的域名。

例如,当我从这样的ssh发送邮件:

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

我想要邮件去[email protected] 。 但是电子邮件发送到[email protected]

我已经审查了我的主机设置,邮件名称设置,后缀设置,我不知道为什么它不断地添加完整的主机名,它显然是反弹。 这是我的configuration文件:

后缀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 

别名:

 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 [email protected] 

的/ etc /邮件名:

 example.com.au 

/ etc / hosts中:

 127.0.0.1 localhost 11x.0.0.xxx host.example.com.au host 

在/ etc /主机名

 host 

我已经审查了一切,我没有线索为什么邮件发送到@host.example.com.au 。 有人可以帮我吗?

我在debian 8上。

编辑:刚才,我尝试添加一个更多的设置main.cf文件: masquerade_domains = $mydomain 。 添加这似乎修复from地址来显示我的域名而不是主机名,但是,地址仍然有FQDN名称。 我收到我的电子邮件地址反弹的电子邮件“邮件传递系统”的通知,因为原来的电子邮件现在是正确的,添加masquerade_domains ,但仍然不能得到我的头,为什么用户的电子邮件不尊重相同,地址仍然以[email protected]代替[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 

你需要在下面的/etc/aliases文件中放入root/etc/aliases ,然后运行newaliases ,它应该可以工作。

 root: [email protected] 

我已经testing过它,它的工作原理。

终于搞定了。 这些是我解决我的麻烦的步骤:

1)mydestination:

由于我只有一个发送邮件服务器,所以我根据postfix手册页将main.cf文件中的mydestination留空。 然而,这样做最终导致上述行为是本地电子邮件与附加的主机名被发送反弹。 因此,我在main.cf添加了$hostnamelocalhost作为mydestination ,如下所示:

 mydestination = $myhostname, localhost 

2)别名:

接下来,我在/etc/aliases添加了root用户的电子邮件地址,如下所示:

 root: [email protected] 

3)newaliases:

最后,我重build别名和重新加载后缀

 sudo newaliases sudo service postfix reload 

什么修正了它:

由于别名仅用于本地交付,我没有本地交付(意思是$ mydestination是空的),具有根别名的电子邮件地址没有任何区别。 现在,在将$hostname添加到我的目的地之后,任何发送给用户的电子邮件都会被追加到$hostname中,然后作为$mydestination被引用,然后引用aliases ,最终告诉postfix将该电子邮件发送到另一个电子邮件地址。

我还不明白的是,为什么后缀忽略了$domainname作为myorigin在第一位,不断添加hostname后缀给用户仍然是一个谜。 然而,上述方法似乎是解决scheme时,后缀坚持要添加hostname直接发送给用户的所有邮件。

希望这可以帮助!

你可以给一个镜头,并尝试添加example.com.au到您的主机文件? 参考: http : //www.tldp.org/LDP/solrhe/Securing-Optimizing-Linux-RH-Edition-v1.3/chap9sec95.html