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

Nee*_*eel 6 email email-server debian postfix fqdn

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

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

echo "This will go into the body of the mail." | mail -s "Hello world" root
Run Code Online (Sandbox Code Playgroud)

我希望邮件转到root@example.com.au. 但是电子邮件发送到root@host.example.com.au.

我已经查看了我的主机设置、邮件名设置、后缀设置,但我不知道为什么它不断向其中添加完整的主机名,而这显然会被退回。这是我的配置文件:

后缀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
Run Code Online (Sandbox Code Playgroud)

别名:

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
Run Code Online (Sandbox Code Playgroud)

/etc/postfix/虚拟:

root            admin@example.com.au
Run Code Online (Sandbox Code Playgroud)

/etc/邮件名:

example.com.au
Run Code Online (Sandbox Code Playgroud)

/etc/hosts:

127.0.0.1       localhost
11x.0.0.xxx   host.example.com.au    host
Run Code Online (Sandbox Code Playgroud)

/etc/主机名

host
Run Code Online (Sandbox Code Playgroud)

我已经查看了所有内容,但我不知道为什么将邮件发送到@host.example.com.au. 有人可以帮我吗?

我在 debian 8 上。

编辑: 刚才,我尝试添加多一个设置main.cf文件:masquerade_domains = $mydomain。添加这似乎修复了from地址以显示我的域名而不是主机名,但是,该to地址仍然具有 FQDN 名称。我在我的电子邮件地址上收到退回的电子邮件“邮件传递系统”通知,因为原始电子邮件现在是在添加 之后masquerade_domains,但仍然无法to理解为什么用户电子邮件不遵守相同的地址并且地址仍然被寻址为root@host.example.com.au而不是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 = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
Run Code Online (Sandbox Code Playgroud)

Nee*_*eel 2

终于成功了。这些是我为解决问题所采取的步骤:

1)我的目的地:

由于我有一个只发送邮件服务器,因此我按照 postfix 手册页将文件留空mydestinationmain.cf然而,这样做最终导致了上述行为,即发送的本地电子邮件附加了主机名,但被退回。因此我添加了$hostnameand如下localhost所示:mydestinationmain.cf

mydestination = $myhostname, localhost
Run Code Online (Sandbox Code Playgroud)

2)别名:

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

root: root@example.com.au
Run Code Online (Sandbox Code Playgroud)

3)新别名:

最后,我重建别名并重新加载后缀

sudo newaliases
sudo service postfix reload
Run Code Online (Sandbox Code Playgroud)

修复了什么:

由于别名仅用于本地传递,并且我没有本地传递(意味着 $mydestination 为空),因此在别名中包含根电子邮件地址没有任何区别。现在,将 添加$hostname到我的目的地后,发送给被附加的用户的任何电子邮件$hostname都会被拾取,因为$mydestinationaliases最终会告诉 postfix 将该电子邮件发送到另一个电子邮件地址。

我仍然不明白的是为什么后缀首先忽略$domainnameas并不断向用户添加后缀仍然是一个谜。然而,当 postfix 坚持将其添加到所有直接发送给用户的邮件时,上述方法似乎是解决方案。myoriginhostnamehostname

希望这可以帮助!