Email

為什麼我不能發送郵件到遠端郵箱?

  • February 9, 2018

我已經在我的 CentOS 機器上安裝了 Postfix。我可以很好地將郵件發送到本地帳戶mutt,但是當我嘗試將一封郵件發送到 myactualmail@gmail.com 之類的遠端郵件時,我不明白為什麼我收不到任何東西。這是我的main.cf

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = server.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
mynetworks = 192.168.200.0/24, 127.0.0.0/8
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
    ddd $daemon_directory/$process_name $process_id & sleep 5


sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

在郵件日誌中,我找到了這些:

Jan 22 14:33:15 server postfix/qmgr[5025]: 316FEBF65E: from=<diego@example.com>, size=430, nrcpt=1 (queue active)
Jan 22 14:33:15 server postfix/smtp[5276]: connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c05::1b]:25: Network is unreachable
Jan 22 14:33:15 server postfix/smtp[5276]: connect to gmail-smtp-in.l.google.com[173.194.66.26]:25: Connection refused
Jan 22 14:33:15 server postfix/smtp[5276]: connect to alt1.gmail-smtp-in.l.google.com[2a00:1450:400c:c05::1a]:25: Network is unreachable
Jan 22 14:33:15 server postfix/smtp[5276]: connect to alt1.gmail-smtp-in.l.google.com[173.194.70.26]:25: Connection refused
Jan 22 14:33:15 server postfix/smtp[5276]: connect to alt2.gmail-smtp-in.l.google.com[2a00:1450:400c:c05::1b]:25: Network is unreachable
Jan 22 14:33:15 server postfix/smtp[5276]: 316FEBF65E: to=<myactualmail@gmail.com>, relay=none, delay=2662, delays=2661/0.04/0.08/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[2a00:1450:400c:c05::1b]:25: Network is unreachable)

但我可以很好地 ping 主機:

ping gmail-smtp-in.l.google.com
PING gmail-smtp-in.l.google.com (173.194.66.26) 56(84) bytes of data.
64 bytes from we-in-f26.1e100.net (173.194.66.26): icmp_seq=1 ttl=128 time=29.2 ms
64 bytes from we-in-f26.1e100.net (173.194.66.26): icmp_seq=2 ttl=128 time=29.6 ms
64 bytes from we-in-f26.1e100.net (173.194.66.26): icmp_seq=3 ttl=128 time=31.0 ms

如果出現配置似乎正常的 SMTP 問題,首先要做的是您實際上可以訪問 SMTP 伺服器。

採用:

telnet gmail-smtp-in.l.google.com 25

你應該看到:

Trying 173.194.69.27...
Connected to gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP lv5si9142984bkb.114 - gsmtp

(在該類型 QUITEnter退出之後)如果沒有顯示您的防火牆(或更可能是您的提供商之一)可能會阻止您。如果可能,請從另一個位置嘗試此操作,以仔細檢查機器是否響應(在您的情況下gmail-smtp-in.l.google.com是響應)。

如果提供商是原因,您可能需要使用其 STMP 伺服器(他們試圖以這種方式防止垃圾郵件從您的系統中流出)。

引用自:https://unix.stackexchange.com/questions/110390