private static bool emailServerLookup(string server) { IPAddress[] mx; try { mx = Dns.GetResolvedMXRecords(server); } catch (Win32Exception w32e) { Log.Instance.HandleException(w32e, LogLevel.Debug); return(false); } if (mx.Length == 0) { return(false); } foreach (IPAddress record in mx) { SmtpClient smtp = new SmtpClient(record); try { if (smtp.Connect().ResponseCode == SmtpResponseCode.ServiceReady && smtp.Hello().ResponseCode == SmtpResponseCode.Completed) { return(true); } } catch (ApplicationException) { continue; } } return(false); }
private static bool emailServerLookup(string server) { IPAddress[] mx; try { mx = Dns.GetResolvedMXRecords(server); } catch (Win32Exception w32e) { Log.Instance.HandleException(w32e, LogLevel.Debug); return false; } if (mx.Length == 0) return false; foreach (IPAddress record in mx) { SmtpClient smtp = new SmtpClient(record); try { if (smtp.Connect().ResponseCode == SmtpResponseCode.ServiceReady && smtp.Hello().ResponseCode == SmtpResponseCode.Completed) return true; } catch (ApplicationException) { continue; } } return false; }