向 cron 发送邮件连接到错误的 IP

向 cron 发送邮件连接到错误的 IP

我正在运行一个装有 Ubuntu 12.04 的服务器,我们有一些 cron 任务可以生成我们想要接收的电子邮件。为了处理这些邮件和其他类似的邮件,我安装了 postfix 并将其配置为只监听本地主机,因为我不希望随机的人尝试将其用作 SMTP 中继。

我可以通过运行以下命令成功发送邮件:

mail [email protected]

但是当 cron 运行时,它会以某种方式尝试连接机器的公共 IP,但会失败,因为它们不受 postfix 的绑定:

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

答案1

根据定义,cron 不连接任何地方来发送电子邮件;它使用 postfix 和其他 MTA 公开的 sendmail(1) 接口。

正如您的日志所示,postfix 正尝试通过 SMTP 将邮件发送给自己;发生这种情况是因为 postfix 不知道它应该处理 einstein.example.com 的邮件。

将域添加到 mydestination 并重新加载 postfix。

相关内容