public static bool Send(MailMessage message) { string domain = MailsSimple.GetDomain(message.To[0].Address); IPAddress[] servers = GetMailExchangeServer(domain); foreach (IPAddress adress in servers) { try { SmtpClient client = new SmtpClient(adress.ToString(), SmtpPort); client.Send(message); return(true); } catch { continue; } } return(false); }
public static bool Send(string from, string to, string subject, string body) { string domain = MailsSimple.GetDomain(to); IPAddress[] servers = GetMailExchangeServer(domain); foreach (IPAddress adress in servers) { try { SmtpClient client = new SmtpClient(adress.ToString(), SmtpPort); client.Send(from, to, subject, body); return(true); } catch { continue; } } return(false); }