unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
IdDNSResolver, IdAntiFreezeBase, IdAntiFreeze, IdMessage,
IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP, StdCtrls;
type
TForm1 = class(TForm)
IdDNSResolver: TIdDNSResolver;
IdSMTP: TIdSMTP;
IdMsgSend: TIdMessage;
IdAntiFreeze1: TIdAntiFreeze;
btnSend: TButton;
edtTo: TEdit;
edtFrom: TEdit;
edtSubject: TEdit;
mmContent: TMemo;
procedure btnSendClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure GetMxList(AMxList: TStringList; AQName: string);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.GetMxList(AMxList: TStringList; AQName: string);
var
i: Integer;
DNSHeader :TDNSHeader;
begin
with IdDNSResolver do
begin
Host := '172.18.3.231';
ReceiveTimeout := 10000; // 在指定的时间内得不到域名服务器的反馈,则视为失败。
AMxList.Clear ; // 清除前一次查询所反馈回来的资源记录
with DNSHeader do
begin
Qr := 0; // False 代表查询
Opcode := 0; // 0代表标准域名查询
RD := 1; //域名服务器可以进行递归查询
QDCount := 1; //查询的数量
end;
{ 构建要查询的问题 }
{QueryResult.Clear;
with QueryResult.Items.Collection.Add. do
begin
QName := AQName; //要查询的域名
QType := cMX; //QTYPE指定要查询的资源记录的种类,值为cMX代表邮件交换记录
QClass := cIN;
end;
}
Resolve('172.18.3.231');
//ResolveDNS; //向域名服务器发出请求
{ 从域名服务器接收反馈的结果,将反馈回来的邮件服务器名称放在AMXList列表的Name
部分,
邮件服务器的优先级别数放在Value部分。 }
for i := 0 to QueryResult.Items[0].Collection.Count - 1 do
AMxList.Add(QueryResult.Items.RData);
end;
end;