Is it possible to instantiate an SMTP client once and send 2000 letters to it synchronously?
We get the following error when creating an instance of the SMTP client for each message sent, using the code also inserted at the end of this message:
System.Net.Mail.SmtpException: service unavailable, closing the transmission channel. Server response: 4.4.1 Connection time from
I suspect that the SMTP client instance for each message causes this, but not sure. The code is as follows.
List<MailMessage> messages = GetMailMessages();
foreach( MailMessags m in messages)
{
try
{
SmtpClient client = new SmtpClient();
client.Send(m);
}
catch (Exception)
{
throw;
}
}
EDIT 1:
MSDN. (http://msdn.microsoft.com/en-us/library/ee706942%28v=vs.110%29.aspx).
, , SMTP- MailMessages.
, SmtpClient SMTP- , SMTP-.
, SMTP . TLS . SMTP- . , , .