2016-09-12 82 views
0

所以我試圖寫一個相當簡單的腳本,其中一部分是發送電子郵件。事情是,腳本運行沒有任何錯誤,一切正常,但我從來沒有收到該電子郵件。我相信,如果成功的話,一些gmail彈出應該會出現,但我不明白。閱讀本教程:https://easyengine.io/tutorials/linux/ubuntu-postfix-gmail-smtp/,但問題仍然存在。任何想法,可以在這裏做什麼?用bash/ubuntu發送電子郵件

我嘗試了測試,並從終端窗口中發送電子郵件 - 同樣的事情

相關main.cf文件的唯一警告是 "warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost =" 還有那些龐大的一羣,即使腳本運行的今天,只有兩次。在main.cf文件 線42 "relayhost = [smtp.gmail.com]:587"

線爲它在我用的是

`mail -s "Subject" -A "info.$NOW.log" [email protected]` 

日誌腳本: Sep 12 09:59:55 shroomz-VirtualBox postfix/qmgr[5372]: 3D892636CF: from=<[email protected]>, size=370, nrcpt=1 (queue active) Sep 12 09:59:55 shroomz-VirtualBox postfix/trivial-rewrite[5481]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 09:59:55 shroomz-VirtualBox postfix/smtp[5482]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 09:59:55 shroomz-VirtualBox postfix/tlsmgr[5483]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 10:00:03 shroomz-VirtualBox postfix/sendmail[5486]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 10:00:03 shroomz-VirtualBox postfix/postdrop[5487]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 10:00:03 shroomz-VirtualBox postfix/cleanup[5488]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 10:00:03 shroomz-VirtualBox postfix/pickup[5371]: 865D06267A: uid=1000 from=<[email protected]> Sep 12 10:00:03 shroomz-VirtualBox postfix/cleanup[5488]: 865D06267A: message-id=<[email protected]> Sep 12 10:00:03 shroomz-VirtualBox postfix/qmgr[5372]: 865D06267A: from=<[email protected]>, size=399, nrcpt=1 (queue active) Sep 12 10:00:03 shroomz-VirtualBox postfix/local[5489]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 10:00:03 shroomz-VirtualBox postfix/bounce[5490]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 10:00:03 shroomz-VirtualBox postfix/local[5489]: 865D06267A: to=<[email protected]>, relay=local, delay=0.04, delays=0.02/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: "sarunas.petkevicius") Sep 12 10:00:03 shroomz-VirtualBox postfix/cleanup[5488]: 8DBE26267C: message-id=<[email protected]> Sep 12 10:00:03 shroomz-VirtualBox postfix/bounce[5491]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 10:00:03 shroomz-VirtualBox postfix/qmgr[5372]: 8DBE26267C: from=<>, size=2406, nrcpt=1 (queue active) Sep 12 10:00:03 shroomz-VirtualBox postfix/bounce[5490]: 865D06267A: sender non-delivery notification: 8DBE26267C Sep 12 10:00:03 shroomz-VirtualBox postfix/qmgr[5372]: 865D06267A: removed Sep 12 10:00:03 shroomz-VirtualBox postfix/local[5489]: 8DBE26267C: to=<[email protected]>, relay=local, delay=0.01, delays=0.01/0/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox) Sep 12 10:00:03 shroomz-VirtualBox postfix/qmgr[5372]: 8DBE26267C: removed Sep 12 10:00:25 shroomz-VirtualBox postfix/smtp[5482]: connect to smtp.gmail.com[74.125.206.108]:587: Connection timed out Sep 12 10:00:25 shroomz-VirtualBox postfix/smtp[5482]: connect to smtp.gmail.com[2a00:1450:400c:c04::6c]:587: Network is unreachable Sep 12 10:00:55 shroomz-VirtualBox postfix/smtp[5482]: connect to smtp.gmail.com[74.125.206.109]:587: Connection timed out Sep 12 10:00:55 shroomz-VirtualBox postfix/bounce[5494]: warning: /etc/postfix/main.cf, line 42: overriding earlier entry: relayhost= Sep 12 10:00:55 shroomz-VirtualBox postfix/smtp[5482]: 3D892636CF: to=<[email protected]n.com>, relay=none, delay=229326, delays=229266/0.06/60/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[74.125.206.109]:587: Connection timed out)

+0

請修改您的問題並添加以下內容:'/ var/log/mail.log'中的'main.cf'錯誤的內容以及您從腳本發送的命令。 –

+0

我希望我現在把所有東西都弄清楚:) –

+0

你有配置問題,請發佈main.cf的內容,加上-v到master.cf,像下面的'smtp inet n - - - - smtpd -v'並重新啓動postfix服務,然後發送另一封電子郵件併發布'/ var/log/mail.log'的內容 –

回答

0

問題是與您的網絡配置,您需要檢查以下內容:

telnet smtp.gmail.com 587 

這可能會產生Unable to connect to remote host: Connection timed out

檢查您的Internet連接,防火牆規則可能阻止傳出587TCP和您的路由表使用ip route list

0
echo "your text " | mail -s subject [email protected] 

並且您必須配置從主機發送的電子郵件,無論您使用的是exim還是postfix。

+0

我的意思不是粗魯,但你有沒有讀過我問過的問題?:)我知道代碼行,但它只是不工作,多數民衆贊成我想弄清楚這裏 –

+0

如果你不能telnet到你的smtp,所以有兩個可能的問題:1.您的互聯網服務提供商可能會阻止smtp端口並且出於安全原因默認必須這樣做。請求ISP檢查設置。如果您一直髮送大量郵件,smtp服務器可能會阻止您。通常谷歌smtp服務器可以阻止用戶至少24小時。 – OlegM