これは、接続から1つのMailMessageを送信するだけです。実際には、接続を適切に閉じることさえできません。メールを送信しますが、終了したいメールサーバーには通知しません。したがって、プールされたストリームがソケットを閉じることを決定するまで、開いたままにしておきます。ここで
はリフレクタからの内部コードです:
...
this.GetConnection();
fileMailWriter = this.transport.SendMail((message.Sender != null) ? message.Sender : message.From, recipients, message.BuildDeliveryStatusNotificationString(), out exception);
}
catch (Exception exception2)
{
if (Logging.On)
{
Logging.Exception(Logging.Web, this, "Send", exception2);
}
if ((exception2 is SmtpFailedRecipientException) && !((SmtpFailedRecipientException) exception2).fatal)
{
throw;
}
this.Abort();
if (this.timedOut)
{
throw new SmtpException(SR.GetString("net_timeout"));
}
if (((exception2 is SecurityException) || (exception2 is AuthenticationException)) || (exception2 is SmtpException))
{
throw;
}
throw new SmtpException(SR.GetString("SmtpSendMailFailure"), exception2);
}
ところで、ここでQUITコマンドを発行していないSmtpClientについての詳細情報です。 https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=146711&wa=wsignin1.0
編集:回避策は、これが速くソケットをクローズします。1.にSmtpClient.ServicePoint.MaxTimeoutを設定することですweb.archive.org
に上記のリンク切れを見る、しかし、これは実際には発行しません。 QUITコマンド。
新しい.NET Frameworkでは 'QUIT'の問題は修正されましたか? – jocull
これはおそらく.NET 4.0で修正されています。https://stackoverflow.com/questions/1466572/net-system-net-mail-smtpclient-class-doesnt-issue-quit-command-to-smtp-transac?noredirect=1 #comment79406662_1466572 – jocull