我正在尝试使用 .NET 的内置 SmtpClient
通过 Amazon SES 新 SMTP 服务发送电子邮件
代码:
var emailClient = new SmtpClient("email-smtp.us-east-1.amazonaws.com", 465);
emailClient.EnableSsl = true;
....
emailClient.Send(message);
我得到一个异常(exception):
Unable to read data from the transport connection: net_io_connectionclosed
Google 说这个错误意味着我无法访问 SMTP 服务器。 他们需要 TLS,我相信这是通过“EnableSsl”属性实现的。
有人知道我需要如何调整我的代码才能使其正常工作吗?
编辑:
我想我会结束这个问题。不,不可能用 SmtpClient 做我想做的事
https://forums.aws.amazon.com/thread.jspa?messageID=302112񉰠
最佳答案
可以通过指定端口 587 来做到这一点。
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network enableSsl="true" port="587" host="email-smtp.us-east-1.amazonaws.com" password="[password]" userName="[username]"/>
</smtp>
</mailSettings>
</system.net>
有了这个配置,你就可以正常使用SmtpClient了
var client = new SmtpClient();
var message = new MailMessage(fromemail, recipient, subject, body);
client.Send(message);
关于c# - 通过 Amazon SES SMTP 错误发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8660714/