Sólo envía un solo MailMessage desde una conexión. De hecho, ni siquiera cierra correctamente la conexión. Envía el correo, pero luego no le dice al servidor de correo electrónico que quiere abandonar. Entonces, simplemente lo deja abierto, hasta que el flujo agrupado subyacente decide cerrar el socket.
Aquí es el código interno del reflector:
...
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);
}
por cierto, aquí es más información sobre la SmtpClient no emite el comando QUIT. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=146711&wa=wsignin1.0
Editar: Ver el vínculo roto por encima de web.archive.org
La solución alternativa es fijar SmtpClient.ServicePoint.MaxTimeout a 1. Esto cerrará el zócalo más rápido, sin embargo, esto no emitir la realidad SALIR comando.
¿Se ha solucionado el problema con 'QUIT' en los frameworks .NET más nuevos? – jocull
Esto fue supuestamente arreglado en .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