我使用的是Ubuntu 12.04运行的服务器,我们有一些cron作业可以生成我们想要接收的邮件。 为了处理这样的邮件和其他邮件,我安装了postfix,并将其configuration为仅在本地主机上侦听,因为我不想随机的人甚至试图使用它作为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,所以我不知道如何开始解决它。 任何人都可以指向正确的方向吗?
我的Postfixconfiguration是非常标准的:
# 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。