在本机电脑上发可以发送成功,编译到linux服务器(linux服务器到smtp主机不通做的代理)上就有问题,报错:
发送失败! {"error": "tls: failed to verify certificate: x509: cannalidate certificate for 10.10.*.* because it doesn't contain any IP SANs"}
解决方案可以使用如下的代码跳过验证:
d.TLSConfig = &tls.Config{InsecureSkipVerify:true}
实例:
if isSSL {
//err = e.SendWithTLS(hostAddr, auth, &tls.Config{ServerName: host})
//代理服务器使用 解决go发邮件问题:tls: failed to verify certificate: x509: certificate signed by unknown authority
err = e.SendWithTLS(hostAddr, auth, &tls.Config{ServerName: host, InsecureSkipVerify: true})
} else {
err = e.Send(hostAddr, auth)
}
```