Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
Check and verify that a smtp-server is up and running?

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

  • 6 aprilie 2006 10:52
     
     

    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

     

Toate mesajele

  • 6 aprilie 2006 11:18
    Moderator
     
     Răspuns
    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.
  • 6 aprilie 2006 12:35
     
     

    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;
       }
    }