开发者

MX validation for mail

开发者 https://www.devze.com 2023-04-13 04:05 出处:网络
I try to use this dll: http://www.eggheadcafe.com/articles/20050129.asp but not working. i always get timeout when running it. Anyone know any good dll or C# example how to check if DNS MX for mail ex

I try to use this dll: http://www.eggheadcafe.com/articles/20050129.asp but not working. i always get timeout when running it. Anyone know any good dll or C# example how to check if DNS MX for mail exist?

code:

private static bool CheckDnsEntry(string domain)
        {
            string[] dnsServer = DnsMx.GetMXRecords(domain);
            if (dnsServer.Length > 0)
            {
                return true;
            }

            return false;
        }


string[] emailparts = email.Split('@');
if (CheckDnsEntry(emailparts[1]))...

ERROR:

Server Error in '/' Application.
Connection timeout
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: Connection timeout

Source Error:

Line 462:        private static bool CheckDnsEntry(string domain)
Line 463:        {
Line 464:            string[] dnsServer = DnsMx.开发者_开发技巧GetMXRecords(domain);
Line 465:            if (dnsServer.Length > 0)
Line 466:            {


You should use some managed dns client for that.

Also when validating MX record ... MX is optional record per SMTP standard. If no MX record, A reord is used instead. (Probably you know it, but in case i noted it out)

There is dnsquery.zip example, what shows show to query different records: http://www.lumisoft.ee/lsWWW/download/downloads/Examples/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号