我正在运行带有 Ubuntu 12.04 的服务器,我们有一些 cron 作业可以生成我们想要接收的电子邮件。为了处理那个和其他类似的邮件,我安装了 postfix 并将其配置为仅在本地主机上侦听,因为我不希望随机的人甚至试图将它用作 SMTP 中继。
我可以通过运行成功发送邮件:
mail [email protected]
但是当 cron 运行时,它会以某种方式尝试连接到机器的公共 IP,但失败了,因为它们不受后缀约束:
Jul 19 09:29:01 einstein cron[5503]: (postgres) RELOAD (crontabs/postgres)
Jul 19 09:29:01 einstein CRON[12119]: (postgres) CMD (ls /)
Jul 19 09:29:01 einstein postfix/pickup[11890]: 5F43928ACE: uid=109 from=<postgres>
Jul 19 09:29:01 einstein postfix/cleanup[12068]: 5F43928ACE: message-id=<[email protected]>
Jul 19 09:29:01 einstein postfix/qmgr[11891]: 5F43928ACE: from=<[email protected]>, size=647, nrcpt=1 (queue active)
Jul 19 09:29:01 einstein postfix/smtp[12073]: connect to einstein.example.com[176.5.13.71]:25: Connection refused
Jul 19 09:29:01 einstein postfix/smtp[12073]: connect to einstein.example.com[2a01:5800::96f1]:25: Connection refused
Jul 19 09:29:01 einstein postfix/smtp[12073]: 5F43928ACE: to=<[email protected]>, orig_to=<postgres>, relay=none, delay=0.01, delays=0/0/0/0, dsn=4.4.1, status=deferred (connect to einstein.example.com[2a01:5800::96f1]:25: Connection refused)
我什至不确定哪个程序连接到错误的 IP,所以我不知道如何开始解决它。谁能指出我正确的方向?
我的 Postfix 配置非常标准:
# This file is managed by puppet, any manual changes will be lost.
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# 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 (Ubuntu)
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 = einstein.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localdomain, localhost, localhost.localdomain, localhost
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
myorigin = /etc/mailname
inet_protocols = all
根据定义,cron 不会连接到任何地方来发送电子邮件;它使用由 postfix 和其他 MTA 公开的 sendmail(1) 接口。
如您的日志所示,postfix 正在尝试通过 SMTP 将邮件发送给自己;发生这种情况是因为 postfix 不知道它应该处理 einstein.example.com 的邮件。
将域添加到 mydestination 并重新加载 postfix。