Detecting if SMTP server is running

B

Ben Fidge

Hi

I'm working on a project where some business process rely on several
external servers to perform processing. These are Sql Server x 2, Credit
Card processing and Mail Server.

Before entering the business process, I'd like to verify that each of these
are available, in particular the SMTP Server, which is the most volatile of
the above servers. What would be the best way to detect if the SMTP server
is up and running?

Ben
 
V

Vadym Stetsyak

To ensure that the server is up you can establish connection with it on port
25. There is a class TcpClient in the .NET Framework. If the server is okay
the first word in the response from it will be code 220 for more details
consult the smtp rfc.

the code to perform connection
TcpClient tcpClient = new TcpClient ();
tcpClient.Connect ("smtp.server.name", 25);
then read the response and check for the status code...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
ClayE7480

Latest Threads

Top