在 Ubuntu 中测试 postfix

在 Ubuntu 中测试 postfix

我正在使用 sendmailR 包通过 Ubuntu 版本 (12.04) 上的 RStudio 发送 .csv 文件。我在 RStudio 中收到完成消息,表示一切顺利,但消息始终未送达。

来自 R:

> sendmail(from=from,to=to,subject=subject,msg=bodyWithAttachment)
$code
[1] "221"

$msg
[1] "2.0.0 Bye"

从 Ubuntu:

$ sudo postfix status
postfix/postfix-script: the Postfix mail system is running: PID: 8576

当我查看日志时:

$ tail -f /var/log/mail.log
Apr 22 15:55:12 bre-dev-2 postfix/qmgr[11718]: B83F424E0140: from=<bre-dev-2@bre-dev-2>, size=1820, nrcpt=1 (queue active)
Apr 22 15:55:12 bre-dev-2 postfix/smtpd[11953]: disconnect from localhost[127.0.0.1]
Apr 22 15:55:12 bre-dev-2 postfix/smtp[11950]: connect to gmail-smtp-in.l.google.com[2607:f8b0:4001:c05::1b]:25: Network is unreachable
Apr 22 15:55:12 bre-dev-2 postfix/smtp[11950]: connect to gmail-smtp-in.l.google.com[74.125.193.27]:25: Connection refused
Apr 22 15:55:12 bre-dev-2 postfix/smtp[11950]: connect to alt1.gmail-smtp-in.l.google.com[2607:f8b0:400d:c04::1b]:25: Network is unreachable
Apr 22 15:55:12 bre-dev-2 postfix/smtp[11950]: connect to alt1.gmail-smtp-in.l.google.com[74.125.29.27]:25: Connection refused
Apr 22 15:55:12 bre-dev-2 postfix/smtp[11950]: connect to alt2.gmail-smtp-in.l.google.com[74.125.131.27]:25: Connection refused
Apr 22 15:55:12 bre-dev-2 postfix/smtp[11950]: B83F424E0140: to=<[email protected]>, relay=none, delay=0.08, delays=0.07/0/0.01/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[74.125.131.27]:25: Connection refused)

以下是 postconf -n 的输出:

lias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mydestination =
myhostname = bre-dev-2
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes

有人能帮我弄清楚这里发生了什么吗?

更新 telnet 的样子如下:

bre-dev-2@bre-dev-2:~$ telnet gmail-smtp-in.l.google.com 25
Trying 74.125.193.27...
Trying 2607:f8b0:4001:c05::1a...
telnet: Unable to connect to remote host: Network is unreachable

答案1

查看日志消息的最后部分:

connect to alt2.gmail-smtp-in.l.google.com[74.125.131.27]:25: Connection refused

事实上,在整个过程中,您都会遇到连接问题。这要么是网络层面的问题,要么是 Google 个人讨厌您。一些 ISP 会阻止直接端口 25,因此请尝试远程登录 Google,看看您会看到什么。以下是我得到的结果:

$ telnet gmail-smtp-in.l.google.com 25
Trying 173.194.78.27...
Connected to gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP c10si1169414wiy.16 - gsmtp
HELO
250 mx.google.com at your service

仔细查看了您的个人资料后,我发现您的 ISP 上的其他人在互联网上提出了许多支持问题,他们在端口 25 上遇到了路由问题。我强烈怀疑这是他们阻止了出站端口 25。

您可以通过另一个 ISP 建立隧道,或者询问您的 ISP 如何发送邮件。Postfix 应该允许您设置中继。或者您甚至可以尝试Gmail 的安全中继端口(并希望您的 ISP 也不会阻止这一点)。

相关内容