I am using a Gmail STMP server to send emails. It works great. But from a few days it sometimes stops working. Now it only works 5 out of 10 times.
Exception: Failure Sending Email
Internal exception: Unable to connect to remote server.
After talking with hosting technical support, they said that their server has a restriction on the mail session. This is Shared Hosting , so when it exceeds all new connections, it is blocked. They said they were trying to fix it. But also, please check that you are closing the mail session properly or not .
I looked at it, but there is no Close() or Dispose() . I also read that there is no confirmation for the SMTP transfer?
Please let me know if there is anyway to close the mail session? Or any workaround to fix this problem.
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 that calls sc.Send() .
Charandeep singh
source share