无法在 Ubuntu 12.04 上通过 bash 脚本发送自动邮件:连接到 mx3.hotmail.com[65.55.37.72]:25:连接超时

无法在 Ubuntu 12.04 上通过 bash 脚本发送自动邮件:连接到 mx3.hotmail.com[65.55.37.72]:25:连接超时

首先,我对我的英语感到抱歉(我是法国人)。

我在用着Ubuntu 桌面 12.04。我仍在学习 Shell 脚本,因此可能在某个地方犯了一个非常简单的错误。

我正在尝试编写一个 shell 脚本,当磁盘空间使用率达到 80% 时向我发送电子邮件。(此脚本将在私人公司托管的远程服务器上的 cron 中使用)

为此,我使用 Postfix sendmail 命令。

问题是我甚至无法使用简单的命令行向我的 hotmail 地址发送测试电子邮件。

我检查了 /var/log/mail.log,这是我得到的结果(在终端中只使用了一个命令):

Dec  2 16:52:18 user-Precision-T3600 postfix/qmgr[7076]: BD8CC1561B8E: from=<user@user-Precision-T3600>, size=317, nrcpt=1 (queue active)
Dec  2 16:52:18 user-Precision-T3600 postfix/qmgr[7076]: 77ED015620AC: from=<user@user-Precision-T3600>, size=443, nrcpt=3 (queue active)
Dec  2 16:52:18 user-Precision-T3600 postfix/qmgr[7076]: DCD541561FDF: from=<user@user-Precision-T3600>, size=443, nrcpt=3 (queue active)
Dec  2 16:52:18 user-Precision-T3600 postfix/qmgr[7076]: AEDC31561FD7: from=<user@user-Precision-T3600>, size=443, nrcpt=3 (queue active)
Dec  2 16:52:18 user-Precision-T3600 postfix/qmgr[7076]: 0C9C815620BC: from=<user@user-Precision-T3600>, size=290, nrcpt=1 (queue active)
Dec  2 16:52:18 user-Precision-T3600 postfix/qmgr[7076]: 3961C15620B6: from=<user@user-Precision-T3600>, size=443, nrcpt=3 (queue active)
Dec  2 16:52:18 user-Precision-T3600 postfix/qmgr[7076]: 6AC1F15620BD: from=<user@user-Precision-T3600>, size=443, nrcpt=3 (queue active)
Dec  2 16:52:48 user-Precision-T3600 postfix/smtp[7930]: connect to mx4.hotmail.com[65.55.37.88]:25: Connection timed out
Dec  2 16:52:48 user-Precision-T3600 postfix/smtp[7931]: connect to mx3.hotmail.com[65.55.37.88]:25: Connection timed out
Dec  2 16:52:48 user-Precision-T3600 postfix/smtp[7929]: connect to mx3.hotmail.com[65.55.37.120]:25: Connection timed out
Dec  2 16:52:48 user-Precision-T3600 postfix/smtp[7932]: connect to mx1.hotmail.com[65.55.92.136]:25: Connection timed out
Dec  2 16:52:48 user-Precision-T3600 postfix/smtp[7928]: connect to mx1.hotmail.com[65.54.188.126]:25: Connection timed out
Dec  2 16:53:18 user-Precision-T3600 postfix/smtp[7931]: connect to mx4.hotmail.com[65.55.37.104]:25: Connection timed out
Dec  2 16:53:18 user-Precision-T3600 postfix/smtp[7928]: connect to mx1.hotmail.com[65.54.188.110]:25: Connection timed out
Dec  2 16:53:18 user-Precision-T3600 postfix/smtp[7929]: connect to mx4.hotmail.com[65.55.92.152]:25: Connection timed out
Dec  2 16:53:18 user-Precision-T3600 postfix/smtp[7932]: connect to mx1.hotmail.com[65.54.188.72]:25: Connection timed out
Dec  2 16:53:18 user-Precision-T3600 postfix/smtp[7930]: connect to mx3.hotmail.com[65.55.92.184]:25: Connection timed out
Dec  2 16:53:48 user-Precision-T3600 postfix/smtp[7932]: connect to mx1.hotmail.com[65.55.92.168]:25: Connection timed out
Dec  2 16:53:48 user-Precision-T3600 postfix/smtp[7931]: connect to mx3.hotmail.com[65.55.37.72]:25: Connection timed out
Dec  2 16:53:48 user-Precision-T3600 postfix/smtp[7928]: connect to mx3.hotmail.com[65.55.92.184]:25: Connection timed out
Dec  2 16:53:48 user-Precision-T3600 postfix/smtp[7929]: connect to mx2.hotmail.com[65.55.37.104]:25: Connection timed out
Dec  2 16:53:48 user-Precision-T3600 postfix/smtp[7930]: connect to mx3.hotmail.com[65.55.92.168]:25: Connection timed out
Dec  2 16:54:18 user-Precision-T3600 postfix/smtp[7932]: connect to mx2.hotmail.com[65.55.92.136]:25: Connection timed out
Dec  2 16:54:18 user-Precision-T3600 postfix/smtp[7928]: connect to mx1.hotmail.com[65.55.37.88]:25: Connection timed out
Dec  2 16:54:18 user-Precision-T3600 postfix/smtp[7931]: connect to mx3.hotmail.com[65.55.92.184]:25: Connection timed out
Dec  2 16:54:18 user-Precision-T3600 postfix/smtp[7929]: connect to mx4.hotmail.com[65.55.37.104]:25: Connection timed out
Dec  2 16:54:18 user-Precision-T3600 postfix/smtp[7930]: connect to mx1.hotmail.com[65.55.37.72]:25: Connection timed out
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7931]: connect to mx4.hotmail.com[65.55.37.88]:25: Connection timed out
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7932]: connect to mx4.hotmail.com[65.55.37.104]:25: Connection timed out
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7928]: connect to mx1.hotmail.com[65.55.92.184]:25: Connection timed out
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7929]: connect to mx4.hotmail.com[65.55.37.120]:25: Connection timed out
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7930]: connect to mx3.hotmail.com[65.55.37.72]:25: Connection timed out
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7932]: 0C9C815620BC: to=<[email protected]>, relay=none, delay=1253, delays=1102/0.02/150/0, dsn=4.4.1, status=deferred (connect to mx4.hotmail.com[65.55.37.104]:25: Connection timed out)
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7928]: BD8CC1561B8E: to=<[email protected]>, relay=none, delay=23169, delays=23019/0.01/150/0, dsn=4.4.1, status=deferred (connect to mx1.hotmail.com[65.55.92.184]:25: Connection timed out)
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7930]: DCD541561FDF: to=<[email protected]>, relay=none, delay=18424, delays=18274/0.01/150/0, dsn=4.4.1, status=deferred (connect to mx3.hotmail.com[65.55.37.72]:25: Connection timed out)
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7931]: AEDC31561FD7: to=<[email protected]>, relay=none, delay=19135, delays=18985/0.02/150/0, dsn=4.4.1, status=deferred (connect to mx4.hotmail.com[65.55.37.88]:25: Connection timed out)
Dec  2 16:54:48 user-Precision-T3600 postfix/smtp[7929]: 77ED015620AC: to=<[email protected]>, relay=none, delay=9121, delays=8971/0.01/150/0, dsn=4.4.1, status=deferred (connect to mx4.hotmail.com[65.55.37.120]:25: Connection timed out)
Dec  2 16:54:48 user-Precision-T3600 postfix/error[7952]: 3961C15620B6: to=<[email protected]>, relay=none, delay=8585, delays=8435/150/0/0.05, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to mx3.hotmail.com[65.55.37.72]:25: Connection timed out)
Dec  2 16:54:48 user-Precision-T3600 postfix/error[7953]: 6AC1F15620BD: to=<[email protected]>, relay=none, delay=8296, delays=8146/150/0/0.06, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to mx3.hotmail.com[65.55.37.72]:25: Connection timed out)

这是我的命令行:

  $ echo foobar | sendmail -i [email protected]

起初我以为是Linux防火墙阻止了该端口,我使用以下命令进行检查:

$ sudo ufw status

这是我得到的:

État : actif

Vers                       Action      Depuis
----                       ------      ------
25                         ALLOW       Anywhere
25/tcp                     ALLOW       Anywhere
25                         ALLOW       Anywhere (v6)
25/tcp                     ALLOW       Anywhere (v6)

我不知道什么不起作用,请帮忙,我已经在这上面几个小时了......

这是 postfix 配置文件(main.cf):

# 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 = bmerlet-Precision-T3600
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = bmerlet-Precision-T3600, localhost.localdomain, , localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

我不知道是否必须更改该文件中的某些参数,如果是的话,我不知道哪一个... :(

我在这里先向您的帮助表示感谢 ;)

答案1

端口 25 很可能被阻止或未被 hotmail 使用。您可以找到更好的参考,但请尝试备用端口,例如端口 465/587。

相关内容