// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Net; using System.Net.Sockets; namespace E { public class Program { public static bool TestMailServer(string server) { try { string ownhost = Dns.GetHostName(); TcpClient client = new TcpClient(server, 25); StreamWriter wrt = new StreamWriter(client.GetStream()); wrt.WriteLine("HELO " + ownhost); wrt.WriteLine("QUIT"); wrt.Flush(); wrt.Close(); client.Close(); return true; } catch { return false; } } public static void Main(string[] args) { Console.WriteLine(TestMailServer("arne")); Console.WriteLine(TestMailServer("arnepc")); Console.WriteLine(TestMailServer("arnepc3")); } } }