sun*_*ide 6 postfix sendmail hostname
我正在尝试设置用于发送电子邮件的外发邮件服务器,以便中继到我们的 ISP。
在 /etc/postfix/main.cf 中,我将 myhostname 指定为 ourcompany.example.com,将 myorigin 和 mydomain 指定为 $myhostname。ourcompany.example.com 是可解析的。
但是查看 /var/log/maillog 中的日志,似乎 postfix 确实使用 myhostname 作为发送地址,但使用了 getmyhostname() 中的任何内容,它被设置为内部 DNS 名称,因为这是一个内部服务器,我们只发送电子邮件,但不处理收到的电子邮件。
有任何想法吗?
编辑:postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost
mydomain = example.com
myhostname = ourcompany.example.com
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.5/README_FILES
relayhost = smtp.grapevine.com.au
sample_directory = /usr/share/doc/postfix-2.6.5/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
Run Code Online (Sandbox Code Playgroud)
ourcompany.example.com 和 example.com 都是公共域,任何人都可以解析,因此应该可以由我的 ISP 解析。问题不在于域,而是 postfix 没有使用它的事实,我得到的日志如下:
May 26 10:23:22 localhost postfix/smtp[3910]: 449AF5803F6: to=<tesing@example.com>, relay=smtp.grapevine.com.au[203.129.32.140]:25, delay=63275, delays=63274/0.02/0.04/0.4, dsn=4.1.8, status=deferred (host smtp.grapevine.com.au[203.129.32.140] said: 450 4.1.8 <benny@server.internal>: Sender address rejected: Domain not found (in reply to RCPT TO command))
Run Code Online (Sandbox Code Playgroud)
它使用 server.internal 而不是 $myorigin,并且 server.internal 是您通过调用 gethostname() 获得的,它是内部主机名,无法在公共互联网上解析。
所以我的问题是,如何将 postfix 设置为使用 example.com 而不是使用 gethostname()?我的想法是 gethostname() 仅在我将 myorigin、mydomain 和 myhostname 留空时使用,但将它们设置为上述设置不会做任何事情。
mydomain = example.com
myorigin = $mydomain
Run Code Online (Sandbox Code Playgroud)
默认情况下,选项append_at_myorigin设置为yes,这意味着任何和所有没有域组件的外发邮件都将附加 myorigin 的值。
在您的情况下,这是域名,而不是主机名。
始终使用完全限定的地址发送邮件,即包含本地部分和有效的现有域/主机名部分。
如果由于某种原因不能,请使用地址重写自述文件中描述的方法之一