I get this error when I often send an email to the user list. Let's say it sends 10 letters, and 1 gives an error, then sends a couple more letters and gives the same error.
The code is as follows:
public static bool SendEmail(string toMail, string fromname, string from, string subject, string body, string BCC) { MailMessage mailmessage = new MailMessage(" frommail@mail.com ", toMail, subject, body); mailmessage.IsBodyHtml = true; mailmessage.BodyEncoding = Encoding.GetEncoding(1254); mailmessage.SubjectEncoding = Encoding.GetEncoding(1254); SmtpClient objCompose = new SmtpClient("xxxx"); try { objCompose.Send(mailmessage); return true; } catch (Exception ex) { } return false; }
And the error I get is this:
System.Net.Mail.SmtpException: the service is unavailable, closing the transmission channel. Server response: 4.4.2 mailer.mailer.com Error: timeout exceeded in System.Net.Mail.MailCommand.CheckResponse (SmtpStatusCode statusCode, string response) in System.Net.Mail.MailCommand.Send (smtpConnection command, Byte command [], line from) on System.Net.Mail.SmtpTransport.SendMail (sender MailAddress, recipients MailAddressCollection, String deliveryNotify, SmtpFailedRecipientException exception and exception) in System.Net.Mail.SmtpClient.Send (MailMessage message)
Can anyone help, this mistake is killing me.
Thanks in advance.
source share