I am using Gmail STMP server to send emails. It works just fine. But from few days, it sometimes stops working. Now, it is only working 5 out of 10
times.
Exception: Failure Sending Email
Inner Exception: Unable to connect to remote server.
After talking to hosting technical support, they said there is a mail session limit on their server. This is a Shared Hosting
, so when it exceeds all new connections are blocking. They said they are trying to fix it. But also said please check that you are closing the mail session properly or not
.
I looked into it, but there is no Close()
or Dispose()
. I also read there is no acknowledgement for SMTP tranfer?
Please let me know if there is anyway to close the mail session? Or any workaround to fix this issue.
Update
I am using System.Net.Mail
MailMessage msg = new MailMessage();
SmtpClient sc = new SmtpClient("smtp.gmail.com", 587);
NetworkCredential info = new NetworkCredential("email", "password");
Then there is another method which calls sc.Send()
.