public IList<MXServer> GetMXServers(string domainName) { string command = "nslookup -q=mx " + domainName; ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; procStartInfo.CreateNoWindow = true; Process proc = new Process(); proc.StartInfo = procStartInfo; proc.Start(); string result = proc.StandardOutput.ReadToEnd(); if (!string.IsNullOrEmpty(result)) result = result.Replace("\r\n", Environment.NewLine); IList<MXServer> list = new List<MXServer>(); foreach (string line in result.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { if (line.Contains("MX preference =") && line.Contains("mail exchanger =")) { MXServer mxServer = new MXServer(); mxServer.Preference = Int(GetStringBetween(line, "MX preference = ", ",")); mxServer.MailExchanger = GetStringFrom(line, "mail exchanger = "); list.Add(mxServer); } } return list.OrderBy(m => m.Preference).ToList(); }
// POST: api/EmailVerifier public MXServer PostEmail(MXServer Server) { MXServer newObj = new MXServer(); if (Server.Email != null) { using (EmailVerifier obj = new EmailVerifier()) { // bool result = verifier.CheckExists(EmailText.Text); newObj = obj.IsEmailVerified(Server.Email); } } return(newObj); }