procedure TForm1.GetMxlist(AMxlist: TStringlist; AQName: string);
var i: integer;
begin
with IdDNSResolver do
begin
Host := '202.101.107.55';
ReceiveTimeout := 10000;
ClearVars;
with DNSHeader do
begin
Qr := False; // False 代表查询
Opcode := 0; // 0代表标准域名查询
RD := True; //域名服务器可以进行递归查询
QDCount := 1; //查询的数量
end;
DNSQDList.Clear;
with DNSQDList.Add do
begin
QName := AQName; //要查询的域名
QType := cMX; //QTYPE指定要查询的资源记录的种类,值为cMX代表邮件交换记录
QClass := cIN;
end;
ResolveDNS; //向域名服务器发出请求
for i := 0 to DNSAnList.Count - 1 do
AMxList.Add(DNSAnList.RData.MX.Exchange + '=' +
IntToStr(DNSAnList.RData.MX.Preference));
end;
end;