我想使用postfix和gmail的smtp服务器(smtp.gmail.com)发送电子邮件(带有centos)。我按照https://charlesauer.net/tutorials/centos/postfix-as-gmail-relay-centos.php在互联网上找到的一些教程。我也创建了一个openssl证书。 现在,当我发送一封电子邮件(使用" mail"命令)时,我可以在我的日志文件末尾读取(/ var / log / maillog):
Jun 27 11:25:23 localhost postfix/smtp[24202]: connect to smtp.gmail.com[74.125.133.108]:587: Connection timed out
Jun 27 11:25:23 localhost postfix/smtp[24202]: connect to smtp.gmail.com[2a00:1450:400c:c07::6c]:587: Network is unreachable
Jun 27 11:25:49 localhost postfix/qmgr[24032]: 186D61A0E6C: from=<user@localhost.localdomain>, size=705, nrcpt=1 (queue active)
Jun 27 11:25:49 localhost postfix/smtp[24226]: connect to smtp.gmail.com[2a00:1450:400c:c07::6c]:587: Network is unreachable
Jun 27 11:25:53 localhost postfix/smtp[24202]: connect to smtp.gmail.com[74.125.133.109]:587: Connection timed out
Jun 27 11:25:53 localhost postfix/smtp[24202]: 31A721A0E71: to=<adresse@gmail.com>, relay=none, delay=208, delays=148/0.02/60/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[74.125.133.109]:587: Connection timed out)
Jun 27 11:26:19 localhost postfix/smtp[24226]: connect to smtp.gmail.com[74.125.133.108]:587: Connection timed out
Jun 27 11:26:49 localhost postfix/smtp[24226]: connect to smtp.gmail.com[74.125.133.109]:587: Connection timed out
Jun 27 11:26:49 localhost postfix/smtp[24226]: 186D61A0E6C: to=<adresse@gmail.com>, relay=none, delay=2253, delays=2193/0.02/60/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[74.125.133.109]:587: Connection timed out)
&#34; nc 74.125.133.108 587 -vv -w3&#34;给我:
libnsock nsi_new2(): nsi_new (IOD #1)
libnsock nsock_connect_tcp(): TCP connection requested to 74.125.133.108:587 (IOD #1) EID 8
libnsock nsock_trace_handler_callback(): Callback: CONNECT TIMEOUT for EID 8 [74.125.133.108:587]
Ncat: Connection timed out.
我认为继电器具有良好的配置(以及后缀),但防火墙阻止了链接。以下是我的配置摘录(&#34; iptables -vnL&#34;):
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
1673 125K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
21M 1986M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
3829 229K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
12405 2187K INPUT_direct all -- * * 0.0.0.0/0 0.0.0.0/0
12405 2187K INPUT_ZONES_SOURCE all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT udp -- eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:465 state NEW,ESTABLISHED
0 0 ACCEPT udp -- eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:587 state NEW,ESTABLISHED
0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:587 state NEW,ESTABLISHED
12405 2187K INPUT_ZONES all -- * * 0.0.0.0/0 0.0.0.0/0
12 480 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID
10843 2104K REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:465
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:587
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:465
0 0 FORWARD_direct all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FORWARD_IN_ZONES_SOURCE all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FORWARD_IN_ZONES all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FORWARD_OUT_ZONES_SOURCE all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 FORWARD_OUT_ZONES all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:465
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:587
那么,我如何配置防火墙以便与gmail的中继通信,以便电子邮件到达目的地? 谢谢!