2011-10-16 40 views
0

我嘗試使用此dll:http://www.eggheadcafe.com/articles/20050129.asp,但無法正常工作。運行時我總是超時。任何人都知道任何好的DLL或C#示例如何檢查郵件的DNS MX是否存在?郵件的MX驗證

代碼:

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]))... 

錯誤:

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

你可以發佈您的調用代碼和調用堆棧例外? –

+1

Uwe我更新了我的問題 – senzacionale

+0

也許你的防火牆阻止訪問DNS? –

回答

1

你應該使用一些管理DNS客戶端爲。

也驗證MX記錄時... MX是每個SMTP標準可選的記錄。 如果沒有MX記錄,則使用替代。 (也許你知道了吧,但萬一我注意到它)

有dnsquery.zip例如,顯示的內容顯示到查詢不同的記錄: http://www.lumisoft.ee/lsWWW/download/downloads/Examples/