![無法在 Ubuntu 12.04 上透過 bash 腳本發送自動郵件:連線到 mx3.hotmail.com[65.55.37.72]:25:連線逾時](https://rvso.com/image/1388128/%E7%84%A1%E6%B3%95%E5%9C%A8%20Ubuntu%2012.04%20%E4%B8%8A%E9%80%8F%E9%81%8E%20bash%20%E8%85%B3%E6%9C%AC%E7%99%BC%E9%80%81%E8%87%AA%E5%8B%95%E9%83%B5%E4%BB%B6%EF%BC%9A%E9%80%A3%E7%B7%9A%E5%88%B0%20mx3.hotmail.com%5B65.55.37.72%5D%3A25%EF%BC%9A%E9%80%A3%E7%B7%9A%E9%80%BE%E6%99%82.png)
首先,我為我的英語道歉(我是法國人)。
我在用著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)
我不知道什麼不起作用,請幫忙,我已經研究了幾個小時了...
這是後綴設定檔(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。