SmtpClient不发送QUIT [英] SmtpClient not sending QUIT

查看:282
本文介绍了SmtpClient不发送QUIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试程序,可以通过Pegasus Mail作者David Harris使用System.Net.Mail.SmtpClient向Mercury SMTP服务器发送电子邮件。 虽然Outlook向此服务器发送电子邮件没有问题,但SmtpClient不会发送Quit命令。 相反,SMTP服务器会在30秒后超时并关闭连接。 我希望它立即关闭连接,以便服务器不等待QUIT命令。 我有一个System.Net.Trace我可以附加,如果这会有帮助。

解决方案

相当奇怪的是需要处理MailMessage和任何附件等  也许将它们包装在一个使用区块中? 完成后,连接立即关闭 - 很遗憾,我无法在 http://找到我链接到的原始邮件www.windows-tech.info/13/187dd6fccdef4fe3.php

I have a test-program to send an email using System.Net.Mail.SmtpClient to the Mercury SMTP server by Pegasus Mail author David Harris.  While Outlook has no issues sending emails to this server, SmtpClient doesn't send the Quit command.  Instead the SMTP server times out after 30 seconds and closes the connection.  I would like it to close the connection immediately so that the Server doesn't wait for the QUIT command.  I have a System.Net.Trace I can append if that would help.

解决方案

Rather wierdly one needs to Dispose the MailMessage and any attachements etc.  Perhaps wrap them in a using block?  After that's done the connection closes promptly -- unfortunately I can't find the original message I linked to at http://www.windows-tech.info/13/187dd6fccdef4fe3.php


这篇关于SmtpClient不发送QUIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆