I have code to send emails that worked fine. We changed hosting companies, so we changed the host and port to the new requirements and it won't send email. We have tried a variety of different setting with no luck.
I need to point out that if we use the exact same setting on an iPhone and Outlook, it works fine.
Here's the code I'm using:
SmtpClient client = new SmtpClient(); client.Host = "Host name"; // Tried named and IP address. client.Port = 587; client.EnableSsl = false; // Tried both true and false. client.UseDefaultCredentials = false; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Credentials = new System.Net.NetworkCredential(strFrom, strSMTPPassword); client.Timeout = 100000; mail.IsBodyHtml = true; try { client.Send(mail); } catch (Exception ex) { }
It always fails. The latest time around we got the following exception messages:
Main: "Failure sending mail."Inner Exception: "Unable to connect to the remote server"Inner exception of that: "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond <PI:Port>"
We are using C#, ASP.Net, .Net v 4.5.
Anybody have any ideas? Like I said - it works in Outlook and via an iPhone and this code worked before changing hosting companies.
TIA.
J.