![无法连接到 SMTP 服务器](https://linux22.com/image/122606/%E6%97%A0%E6%B3%95%E8%BF%9E%E6%8E%A5%E5%88%B0%20SMTP%20%E6%9C%8D%E5%8A%A1%E5%99%A8%20.png)
我无法与我的服务器的 SMTP 服务器建立连接,它会立即关闭。
telnet x.x.x.x 25
Trying x.x.x.x...
Connected to xxxxxx.xxx.
Escape character is '^]'.
Connection closed by foreign host.
Postfix的main.cf配置:
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtp_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_use_tls = yes
smtpd_tls_loglevel = 1
smtpd_tls_cert_file = /etc/ssl/certs/postfix.pem
smtpd_tls_key_file = /etc/ssl/private/postfix.pem
smtpd_tls_auth_only = yes
smtp_tls_security_level = may
邮件日志(启用详细 smtpd):
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: connection established
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: master_notify: status 0
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: name_mask: resource
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: name_mask: software
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: connect from \[xx.xxx.xx.x]
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_list_match: myisphostname: no match
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_list_match: xx.xxx.xx.x: no match
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_list_match: myisphostname: no match
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_list_match: xx.xxx.xx.x: no match
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_hostname: myisphostname ~? 127.0.0.0/8
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_hostaddr: xx.xxx.xx.x ~? 127.0.0.0/8
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_hostname: myisphostname ~? yy.yy.yyy.y/24
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_hostaddr: xx.xxx.xx.x ~? yy.yy.yyy.y/24
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_list_match: myisphostname: no match
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_list_match: xx.xxx.xx.x: no match
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: send attr request = connect
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: send attr ident = smtp:xx.xxx.xx.x
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: private/anvil: wanted attribute: status
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute name: status
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute value: 0
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: private/anvil: wanted attribute: count
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute name: count
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute value: 1
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: private/anvil: wanted attribute: rate
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute name: rate
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute value: 1
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: private/anvil: wanted attribute: (list terminator)
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute name: (end)
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: > myisphostname[xx.xxx.xx.x]: 220 mydomain.com ESMTP Postfix
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: smtp_get: EOF
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_hostname: myisphostname ~? 127.0.0.0/8
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_hostaddr: xx.xxx.xx.x ~? 127.0.0.0/8
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_hostname: myisphostname ~? yy.yy.yyy.y/24
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_hostaddr: xx.xxx.xx.x ~? yy.yy.yyy.y/24
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_list_match: myisphostname: no match
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: match_list_match: xx.xxx.xx.x: no match
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: send attr request = disconnect
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: send attr ident = smtp:xx.xxx.xx.x
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: private/anvil: wanted attribute: status
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute name: status
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute value: 0
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: private/anvil: wanted attribute: (list terminator)
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: input attribute name: (end)
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: lost connection after CONNECT from myisphostname[xx.xxx.xx.x]
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: disconnect from myisphostname[xx.xxx.xx.x]
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: master_notify: status 1
Nov 28 11:08:32 serverhostname postfix/smtpd[2609]: connection closed
答案1
发现问题所在:Little Snitch 防火墙阻止与 SMTP 服务器的连接。
(捂脸)