Check and verify that a smtp-server is up and running?

Hey there.
I have an application in C#, that is depending on the fact that a smtp-server is valid and running.
Is there any way of checking if a given smtp-server is "alive"

SmtpClient smtpclient = New SmtpClient(<server>);

/Kristian



Answer this question

Check and verify that a smtp-server is up and running?

  • PupDaddy

    You can try to handshake with the Smtp server, it the handshake could be done everything is running normally.

    Take a look at the Smtp protocol how to implement an handshake or take a look at the following article that demostrates how to then email with C#. It implements all commands and you can just pickout the handshake process: Sending email with c# using SMTP Servers.


  • cliftonic

    Thanks.
    The following solved it:


    using System.Net.Sockets;

    public bool Handshake()
    {
       Try
       {
          TcpClient tcp = New TcpClient();
          tcp.Connect(<smtpHost>, 25);
          return true;
       }
       Catch (Exception myException)
       {
          return false;
       }
    }


  • Check and verify that a smtp-server is up and running?