2

I have an MVC3 web application written in C#. I am using McvMailer to send emails from within the application, which is all working fine.

The issue i have is that our smtp server is not anywhere near the web server that will be hosting the application, and that it is possible that on occasion the smtp server may not be available.

I need to be able to detect whether or not the smtp server is available before giving a user the option to send emails. Thus far the best i have come up with is to ping the smtp server using the solution from @John Leidegren answer in this post.

However, it appears that the router is responding to the ping and not the smtp server. Baring in mind that the main cause for the server not being available would be the internet connection failing, i could probably live with this solution if i had to, but it would be nice if i could ensure the availability of the smtp service prior to attempting to send emails.

Any ideas?

Community
  • 1
  • 1
Ben
  • 5,525
  • 8
  • 42
  • 66

1 Answers1

3

Yes, ping is a good start, but to determine if the SMTP gateway is available, issue the HELO command through the SMTP port.

I'll try to find a good example.

Edit:

You're in luck. Here's a complete TELNET client written in C#. https://www.nuget.org/packages/Telnet

Chris Gessler
  • 22,727
  • 7
  • 57
  • 83