예제 #1
0
        /// <summary>
        /// Get the MX records for the specified domain name using the specified DNS server.
        /// </summary>
        /// <param name="address">The domain name.</param>
        /// <param name="host">The host name of the DNS server to use.</param>
        /// <param name="port">The port number of the DNS server to use.</param>
        /// <param name="timeout">The timeout in miliseconds.</param>
        /// <returns>A collection of Mx Records.</returns>
        public static MxRecordCollection GetMxRecords(string address, string host, int port, int timeout)
        {
            var mxRecords = new MxRecordCollection();
            var query     = new DnsQuery(IPAddress.Parse(host))
            {
                RecursiveQuery = true,
                DnsServer      = { Port = port },
                Domain         = address
            };
            DnsAnswer answer = query.QueryServer(RecordType.MX, timeout);

            foreach (Answer entry in answer.Answers)
            {
                var mxRecord = (MXRecord)entry.Data;
                mxRecords.Add(mxRecord.Domain, mxRecord.Preference);
            }

            return(mxRecords);
        }
예제 #2
0
        /// <summary>
        /// Get the MX records for the specified domain name using the specified DNS server.
        /// </summary>
        /// <param name="address">The domain name.</param>
        /// <param name="host">The host name of the DNS server to use.</param>
        /// <param name="port">The port number of the DNS server to use.</param>
        /// <param name="timeout">The timeout in miliseconds.</param>
        /// <returns>A collection of Mx Records.</returns>
        public static ActiveUp.Net.Mail.MxRecordCollection GetMxRecords(string address, string host, int port, int timeout)
        {
            MxRecordCollection mxRecords = new MxRecordCollection();

            DnsQuery query = new DnsQuery(IPAddress.Parse(host));

            query.RecursiveQuery = true;
            query.DnsServer.Port = port;
            query.Domain         = address;

            DnsAnswer answer = query.QueryServer(RecordType.MX, timeout);

            foreach (DnsEntry entry in answer.Answers)
            {
                MXRecord mxRecord = (MXRecord)entry.Data;

                mxRecords.Add(mxRecord.Domain, mxRecord.Preference);
            }

            return(mxRecords);
        }
예제 #3
0
    /// <summary>
	/// Get the MX records for the specified domain name using the specified DNS server.
	/// </summary>
	/// <param name="address">The domain name.</param>
	/// <param name="host">The host name of the DNS server to use.</param>
	/// <param name="port">The port number of the DNS server to use.</param>
    /// <param name="timeout">The timeout in miliseconds.</param>
    /// <returns>A collection of Mx Records.</returns>
	public static ActiveUp.Net.Mail.MxRecordCollection GetMxRecords(string address, string host, int port, int timeout)
	{
        MxRecordCollection mxRecords = new MxRecordCollection();

        DnsQuery query = new DnsQuery(IPAddress.Parse(host));

        query.RecursiveQuery = true;
        query.DnsServer.Port = port;
        query.Domain = address;
  
        DnsAnswer answer = query.QueryServer(RecordType.MX, timeout);

        foreach (DnsEntry entry in answer.Answers)
        {
            MXRecord mxRecord = (MXRecord)entry.Data;

            mxRecords.Add(mxRecord.Domain, mxRecord.Preference);
        }
        		
		return mxRecords;
	}