Z
zhx_888
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
LSMTP: TIdSMTP;
LSMG: TidMessage;
begin
Memo1.Lines :=Getips();
Lsmtp:=TidSmtp.Create(Nil);
LSMTP.Host :=SMTPHOST;
Memo2.Lines.Clear ;
memo2.Lines.Add ('连接到服务器:'+LSMTP.Host );
LSMTP.Connect();
IF LSMTP.Connected THEN
begin
memo2.Lines.Add ('已经连接到服务器');
memo2.Lines.Add(LSMTP.AuthSchemesSupported.GetText );
IF (LSMTP.AuthSchemesSupported.IndexOf ( 'LOGIN' ) <> -1) THEN
BEGIN
Memo2.lines.add('服务器要求身份验证');
LSMTP.Username :=USELOGINNAME;
lsmtp.Password :=USEPASSWORD;
lsmtp.AuthenticationType :=atlogin;
Memo2.lines.add('开始身份验证');
IF lsmtp.Authenticate THEN
Memo2.lines.add('身份验证通过')
else
begin
Memo2.lines.add('身份验证失败!');
lsmtp.Disconnect ;
Memo2.lines.add('连接已断开!');
end;
MEMO2.Lines.AddStrings(LSMTP.LastCmdResult.Text );
END;
IF LSMTP.Connected THEN
BEGIN {开始发邮件}
Memo2.lines.add('开始发送邮件!');
LSmG:=TidMessage.Create(LSMTP);
LSMG.Subject :='IP Address :'+GetIPs().GetText ;
LSMG.From.Address :=USEADDRESS;
LSMG.From.Name :=USENAME;
LSMG.ReceiptRecipient.Address :=TOADDRESS;
LSMG.Date :=NOW;
LSMG.Priority :=MPHIGH;
LSMTP.SendMsg(LSMG,True);
LSMTP.Disconnect ;
Memo2.lines.add('连接已断开!');
lsmg.Destroy ;
END
else
Memo2.lines.add('连接失败!');
end;
lsmtp.Destroy ;
end;
注:GETIPS()过程用于获取本机IP放到 MEMO1 框中
MEMO2框显示信息
var
LSMTP: TIdSMTP;
LSMG: TidMessage;
begin
Memo1.Lines :=Getips();
Lsmtp:=TidSmtp.Create(Nil);
LSMTP.Host :=SMTPHOST;
Memo2.Lines.Clear ;
memo2.Lines.Add ('连接到服务器:'+LSMTP.Host );
LSMTP.Connect();
IF LSMTP.Connected THEN
begin
memo2.Lines.Add ('已经连接到服务器');
memo2.Lines.Add(LSMTP.AuthSchemesSupported.GetText );
IF (LSMTP.AuthSchemesSupported.IndexOf ( 'LOGIN' ) <> -1) THEN
BEGIN
Memo2.lines.add('服务器要求身份验证');
LSMTP.Username :=USELOGINNAME;
lsmtp.Password :=USEPASSWORD;
lsmtp.AuthenticationType :=atlogin;
Memo2.lines.add('开始身份验证');
IF lsmtp.Authenticate THEN
Memo2.lines.add('身份验证通过')
else
begin
Memo2.lines.add('身份验证失败!');
lsmtp.Disconnect ;
Memo2.lines.add('连接已断开!');
end;
MEMO2.Lines.AddStrings(LSMTP.LastCmdResult.Text );
END;
IF LSMTP.Connected THEN
BEGIN {开始发邮件}
Memo2.lines.add('开始发送邮件!');
LSmG:=TidMessage.Create(LSMTP);
LSMG.Subject :='IP Address :'+GetIPs().GetText ;
LSMG.From.Address :=USEADDRESS;
LSMG.From.Name :=USENAME;
LSMG.ReceiptRecipient.Address :=TOADDRESS;
LSMG.Date :=NOW;
LSMG.Priority :=MPHIGH;
LSMTP.SendMsg(LSMG,True);
LSMTP.Disconnect ;
Memo2.lines.add('连接已断开!');
lsmg.Destroy ;
END
else
Memo2.lines.add('连接失败!');
end;
lsmtp.Destroy ;
end;
注:GETIPS()过程用于获取本机IP放到 MEMO1 框中
MEMO2框显示信息