예제 #1
0
        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);
        }
예제 #2
0
        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);
        }