MX validation for mail

浪尽此生 提交于 2020-01-06 16:18:30

问题


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:            {

回答1:


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/



来源:https://stackoverflow.com/questions/7786155/mx-validation-for-mail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!