Okay. Yesterday I was stuck in SocketException on Plesk panel using Godaddy.com service. The solution was rather easy. It is detailed on here. To solve this issue:
In your code use the below SMTP configuration:
String message = "Name:\r\n"+Name+"Message:"+Message+"\r\n"; MailMessage mail = new MailMessage(); mail.From = new MailAddress("firstname.lastname@example.org"); mail.To.Add(new MailAddress("email@example.com")); mail.Subject = "Enquiry for Godaddy Testing."; mail.Body = message; SmtpClient client = new SmtpClient(); client.Send(mail);
Now in the web.config file add below Mail settings:
<configuration> <system.web> <compilation debug="true" targetFramework="4.6.1"/> <httpRuntime targetFramework="4.6.1"/> </system.web> <system.net> <mailSettings> <smtp from="firstname.lastname@example.org"> <network host="relay-hosting.secureserver.net" port="25" /> </smtp> </mailSettings> </system.net>
That’s it. Mail will be sent using From email address only. Don’t worry. The mail send using this code will be delayed for few seconds but it will be delivered.