这是代码
memo1.Clear;
memo1.Lines.Add(FileName);
SMTP1.AuthenticationType := atLogin;
SMTP1.UserId:=smtpid; //帐号
SMTP1.Password := smtppwd; //密码
SMTP1.Host := smtpip; //服务器
SMTP1.Port :=25;
try
SMTP1.Connect ;
except
// Showmessage('连接SMTP服务器失败!');
Exit;
end;
try
with IdMsg do
begin
body.Clear;
Body.Assign(memo1.lines); //付件
From.address :='fdf; ///发件人
Recipients.EMailAddresses :=ADOQuery1.fieldbyname('email').AsString; //收件人
Subject:='sdfds' //主题
end;
SMTP1.Send(IdMsg);
finally
// showmessage('您的信件已成功发送');
SMTP1.Disconnect;
end;
下面是提示这个错误:
502 Error:command not implemented
网上找了很多,也没有发现解决的办法,高手们帮帮忙
smtpid,smtppwd,smtpip在程序启动的时候就已经获取到了
http://www.delphibbs.com/keylife/iblog_show.asp?xid=15796
procedure TDMMain.DataModuleCreate(Sender: TObject);
begin
IdSMTP.Host := 'SMTP.126.COM';
IdSMTP.Username := '****';
IdSMTP.Password := '****';
IdSMTP.MailAgent := 'Heynoon CO.';
IdSMTP.HeloName := 'Heynoon';
IdSMTP.AuthenticationType := atLogin;
end;procedure TMailThread.SendMail(const EmailAddr, Subject, Msg: string);
begin
FDM.IdMsg.Clear;
FDM.IdMsg.From.Address := ****';
FDM.IdMsg.Recipients.EMailAddresses := EmailAddr;
FDM.IdMsg.Subject := Subject;
FDM.IdMsg.Body.Text := Msg; FDM.IdSMTP.Connect(cTimeoutLimit);
try
FDM.IdSMTP.Send(FDM.IdMsg);
finally
FDM.IdSMTP.Disconnect;
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,DateUtils,
IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP;type
TForm1 = class(TForm)
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
try
IdSMTP1.Host:='172.50.109.43';
IdSMTP1.Username:='test';
IdSMTP1.Password:='1234';
IdSMTP1.Port:=25;
IdSMTP1.AuthenticationType:=atLogin;
IdSMTP1.Connect;
IdMessage1.Recipients.EMailAddresses:='[email protected]';
IdMessage1.From.Address:='[email protected]';
IdMessage1.Subject:='Love mail';
IdMessage1.Body.Text:='Dear Wife,'+#13#10+' If you receive this Email,That is what I miss you......'+#13+#13+'Success_ju'+#13+formatdatetime('yyyy/mm/dd',Now);
IdSMTP1.Authenticate;
IdSMTP1.Send(IdMessage1);
ShowMessage('@_@發送成功!');
IdSMTP1.Disconnect;
except
IdSMTP1.Disconnect;
Showmessage('@^^@發送失敗!');
Exit;
end;
end;end.