# SMTP 连接超时：连接到 smtp.example.com 端口 587 超时

- **ID:** `communication/smtp-connection-timeout-port-587`
- **领域:** communication
- **类别:** network_error
- **错误码:** `ETIMEDOUT`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

防火墙或网络策略阻止了到端口 587（STARTTLS）的出站连接，而端口 25 或 465 可能开放，或者 SMTP 服务器因 DNS 或路由问题无法访问。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Postfix 3.7.0 | active | — | — |
| Exim 4.96 | active | — | — |
| sendmail 8.17.1 | active | — | — |

## 解决方案

1. ```
   Switch to port 465 with implicit SSL/TLS: import smtplib; server = smtplib.SMTP_SSL('smtp.example.com', 465); server.login(user, password); server.sendmail(from_addr, to_addrs, msg)
   ```
2. ```
   Contact network administrator to open outbound port 587 in firewall rules
   ```
3. ```
   Use a relay server on a different port (e.g., 2525) if provider supports it
   ```

## 无效尝试

- **** — Port 587 is blocked by firewall; longer timeout doesn't bypass firewall (90% 失败率)
- **** — Telnet also fails if port is blocked; doesn't solve the underlying issue (95% 失败率)
- **** — Port 25 may be blocked by ISPs or flagged as spam; also insecure (70% 失败率)
