Failure sending mail. Unable to write data to the transport connection(邮件发送失败.无法将数据写入传输连接)
问题描述
我正在使用 Gmail SMTP 服务器从 VB.Net 发送邮件.尽管它可以正常发送一些电子邮件,但对于其他一些电子邮件,它会返回以下错误:
I am using a Gmail SMTP server to send mail from VB.Net. Although it sends some emails fine, for some others it returns the following error:
发送邮件失败.无法将数据写入传输连接 System.Net.Sockets.SocketException:已建立的连接被主机中的软件中止
Failure sending mail. Unable to write data to the transport connection System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
推荐答案
我最近遇到了同样的问题,SmtpClient.SendMail(MailMessage)
被重复用于带有 350k 附件的电子邮件.每隔 33 条消息,就会出现您给出的错误.
I was experiencing this same issue recently with SmtpClient.SendMail(MailMessage)
being used repeatedly with an email with a 350k attachment. Every 33rd message, the error you gave would occur.
原来我们封装了 SendMail 功能的共享组件在消息发送完成时没有在 SmtpClient
类上调用 Dispose()
.
Turns out our shared component which encapsulated the SendMail functionality was not calling Dispose()
on the SmtpClient
class when the message was finished sending.
将 client.Dispose()
添加到 SmtpClient 实例立即解决了问题,现在消息发出没有问题 - 数百条(是的,它们是给我们客户的合法产品通知,而不是垃圾邮件);)
Adding client.Dispose()
to the SmtpClient instance cleared the problem right up and now messages go out no problem - hundreds of them (and yes they're legitimate product notifications to our customers, not spam) ;)
这篇关于邮件发送失败.无法将数据写入传输连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:邮件发送失败.无法将数据写入传输连接
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- C# 中多线程网络服务器的模式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01