我在 Ubuntu 14.04 服务器上全新安装了 postfix,但我发送的测试电子邮件都在电子邮件地址中包含主机名。我搜索后发现有不少人遇到同样的问题,但他们的解决方案对我都不起作用/不适用。我尝试了各种教程中的选项,但似乎没有得到与他们相同的结果。
我的 /etc/postfix/main.cf:
mydomain = example.com
myorigin = example.com
smtpd_banner = $mydomain ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
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
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = merlin.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname localhost.$mydomain localhost $mydomain
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
我的 /etc/hosts 文件是:
127.0.0.1 localhost
XX.XX.XX.XX merlin.example.com merlin
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
收到的邮件头示例为:
Delivered-To: [email protected]
Received: by 10.107.173.142 with SMTP id m14csp624755ioo;
Sun, 3 Apr 2016 01:12:36 -0700 (PDT)
X-Received: by 10.66.101.35 with SMTP id fd3mr43641306pab.7.1459671156649;
Sun, 03 Apr 2016 01:12:36 -0700 (PDT)
Return-Path: <[email protected]>
Received: from merlin.example.com (xxx-89-xx-64.xxx.xxx.xx.xx. [xxx.89.xx.64])
by mx.google.com with ESMTP id n69si18026934pfi.104.2016.04.03.01.12.36
for <[email protected]>;
Sun, 03 Apr 2016 01:12:36 -0700 (PDT)
Received-SPF: neutral (google.com: xxx.89.xx.64 is neither permitted nor denied by best guess record for domain of [email protected]) client-ip=xxx.89.xx.64;
Authentication-Results: mx.google.com;
spf=neutral (google.com: xxx.89.xx.64 is neither permitted nor denied by best guess record for domain of [email protected]) [email protected]
Received: by merlin.example.com (Postfix, from userid 1000)
id 02854601326; Sun, 3 Apr 2016 20:12:12 +1200 (NZST)
我看不出我的设置有什么问题,并且根据查看的结果更改了我能想到的尽可能多的选项http://www.postfix.org/。每次更改后我都会重新启动 postfix。
我将非常感激任何建议 :)
答案1
摘录自Postfix 帮助:
外发邮件使用什么域名
这肌源参数指定在此机器上发布的邮件中出现的域。默认使用本地机器名称,$我的主机名,默认为机器名称。除非你运行的是一个很小的网站,否则你可能希望将其更改为$我的域名,默认为机器名的父域。
为了发件人和收件人地址的一致性,肌源还指定附加到不合格收件人地址的域名。
示例(仅指定下列之一):
/etc/postfix/main.cf:
myorigin = $myhostname (default: send mail as "user@$myhostname")
myorigin = $mydomain (probably desirable: "user@$mydomain")
答案2
我并不是 Postfix 方面的专家,但我没有在您的配置中看到 mydomain 指令。
我的配置设置如下:
mydomain = example.com myorigin = $mydomain