d6下:
procedure Tform1.SendAlarmEmail;
begin
if SMTPAuthority then //SMTPAuthority 是 表示这个SMTP服务器是否需要认证的boolean
SMTP.AuthenticationType := atLogin
else SMTP.AuthenticationType := atNone;
SMTP.UserID := myzerg@263.net;//帐户
SMTP.Password := **********;//密码
{General setup}
SMTP.Host := SMTP.263.net;
SMTP.Port := 25;
try
SMTP.Connect;
except
Showmessage('连接SMTP服务器失败!');
Exit;
end;
try
with IdMsgSend do
begin
body.Clear;
Body.Add('hello world');//内容
From.Text := 'myzerg@263.net';
Recipients.EMailAddresses :='zyx_chz@263.net'//收件人
Subject:='老友,哈喽'//主题
end;
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end;
end;