fix: 外发优先走 IPv4(Gmail 拒收无 PTR 的 IPv6);新增 smarthost 中继支持

- 出站 SMTP 连接强制 IPv4(tcp4),无 MX 回退时 IPv4 优先:
  住宅/动态 IP 的 IPv6 临时地址通常无 PTR,Gmail 会以 5.7.25 拒收,
  而 IPv4 一般具备正反向一致的 PTR(实测 Gmail 250 OK)
- [outbound] 新增 relay_host/relay_port/relay_user/relay_password/
  relay_starttls:配置后所有外部投递经智能主机中继(AUTH PLAIN、
  465 隐式 TLS / 其他端口 STARTTLS),解决服务器 IP 被 Spamhaus PBL
  收录时 Outlook/Hotmail 拒收的问题
- 新增 smarthost 中继单元测试
This commit is contained in:
dsh
2026-08-15 23:39:57 -04:00
parent 3bc33214c3
commit 75a1619c68
5 changed files with 308 additions and 24 deletions
+11
View File
@@ -56,6 +56,17 @@ func NewManager(cfg config.OutboundConfig, hostname string, stores *store.Stores
lim: make(map[uint]*userWindow),
batch: 50,
}
if cfg.RelayHost != "" {
m.mailer.Relay = &RelayConfig{
Host: cfg.RelayHost,
Port: cfg.RelayPort,
Username: cfg.RelayUser,
Password: cfg.RelayPassword,
StartTLS: cfg.RelayStartTLS,
}
log.Printf("outbound: using smarthost relay %s:%d", cfg.RelayHost, cfg.RelayPort)
}
return m
}