发送邮件失败。无法将数据写入传输连接

发布于 2024-11-03 13:24:50 字数 185 浏览 3 评论 0原文

我正在使用 Gmail SMTP 服务器从 VB.Net 发送邮件。尽管它可以正常发送一些电子邮件,但对于其他一些电子邮件,它会返回以下错误:

发送邮件失败。无法将数据写入传输连接 System.Net.Sockets.SocketException:主机中的软件中止了已建立的连接

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:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酷到爆炸 2024-11-10 13:24:50

最近,我在使用带有 350k 附件的电子邮件时重复使用 SmtpClient.SendMail(MailMessage) 时遇到了同样的问题。每第 33 条消息,就会出现您给出的错误。

事实证明,当消息发送完成时,封装 SendMail 功能的共享组件没有调用 SmtpClient 类上的 Dispose()

client.Dispose() 添加到 SmtpClient 实例立即解决了问题,现在消息发送没有问题 - 数百条消息(是的,它们是给我们客户的合法产品通知,而不是垃圾邮件); )

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.

Turns out our shared component which encapsulated the SendMail functionality was not calling Dispose() on the SmtpClient class when the message was finished sending.

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) ;)

故事↓在人 2024-11-10 13:24:50

根据我在网上看到的信息,与此异常相关的Winsock错误代码是WSAECONNABORTED

您可以在以下地址阅读更多相关内容以获取解释: WSAECONNABORTED

基本上这意味着当您的应用程序尝试发送大电子邮件时,服务器关闭了连接。

也许您应该检查 Gmail 文档,看看它是否对邮件大小或发送的邮件总数有一些限制。看来您在套接字上传输了太多数据。

From what I read on the net, the Winsock error code associated with this exception is WSAECONNABORTED.

You can read more about it at this address for an explanation: WSAECONNABORTED

Basically it means that the server closed the connection while your application was trying to send a large e-mail.

Maybe you should check the Gmail documentation to see if it has some limitation on message size, or total number of messages sent. Looks like you're pumping too much data on the socket.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文