-1

I wrote this code in asp.net for sending email:

MailMessage mailObject = new MailMessage("a@b.com(I use fake email, exactly this email)", "info@mydomain.com", "contact us", "Test message");
SmtpClient smtpC = new SmtpClient("my smtp server name");
smtpC.Send(mailObject);

But I receive this exception:

System.Net.Sockets.SocketException: 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

Also I can not connect to my "smpt server name" via tel net:

telnet SMTPServerName 25 Connecting To SMTPServerName...Could not open connection to the host, on port 25: Connect failed

Is there any standard for troubleshooting this?

Masoud Keshavarz
  • 2,166
  • 9
  • 36
  • 48

1 Answers1

2

Most likely the server name or port is incorrect. Make sure you can send from an SMTP client before troubleshooting further in your code.

Jon B
  • 51,025
  • 31
  • 133
  • 161