5
51zhan.com
Unregistered / Unconfirmed
GUEST, unregistred user!
具体的错误详细信息为:
---------------------------
Debugger Exception Notification
---------------------------
Project SfMail.exe raised exception class EIdSMTPReplyError with message 'authentication is required,mx13,wKjANLArSgCdPH9FyPaWGg==.32169S3 1165966493
'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
unit teml; interface
uses Windows,Classes,Sysutils,Dialogs,
IdSMTP,IdMessage,IdDNSResolver;
type TEMAIL=class(TObject)
private
function GetMxList(dns,dmn:string):TstringList;
function EmailAddrTest(a:string):boolean;
function EmailGetDomain(a:string):string;
function EmailGetName(a:string):string;
public
function EMS(vto,vfrom,vname,vsub:string;vbody:TstringList):boolean;
function NamelessEMS(vto,vsub:string;vbody:tstringlist):boolean;
end;
var EMAIL:TEMAIL;
implementation
function TEMAIL.EmailAddrTest(a:string):boolean;
var s:string; k,n,p:INTEGER;
begin
Result := false; if length(a)<5 then exit;
p := pos('@',a); if (p=0)or(p=length(a))or(p=1) then exit;
n := 0;
for k := 1 to length(a) do if a[k]='@' then inc;
if n<>1 then exit;
Result := true;
end;
function TEMAIL.EmailGetDomain(a:string):string;
var p:INTEGER;
begin
Result := '';
if not EmailAddrTest(a) then exit;
p := pos('@',a);
Result := COPY(a,p+1,Length(a)-p);
end;
function TEMAIL.EmailGetName(a:string):string;
var p:INTEGER;
begin
Result := '';
if not EmailAddrTest(a) then Exit;
p := POS('@',a);
Result := COPY(a,1,p-1);
end;
function TEMAIL.EMS(vto,vfrom,vname,vsub:string;vbody:TstringList):boolean;
var Smtp:TIdSmtp;
Msg:TIdMessage;
s,sMX,sDomain:string; k,m,p:INTEGER;
MX:TstringList;
begin
Result := false;
if not (EmailAddrTest(vto) and EmailAddrTest(vfrom)) then Exit;
sDomain:=EmailGetDomain(vto);
if sDomain='' then Exit;
MX := GetMxList('',sDomain);
if MX.Count<1 then begin MX.Free; end;
sMX := MX[0]; MX.Free;
Msg := TIdMessage.Create(NIL);
Msg.Subject := vsub;
Msg.Body.Addstrings(vbody);
Msg.Recipients.EMailAddresses := vto;
Msg.From.Address := vfrom;
Msg.From.Name := vname;
Smtp := TIdSmtp.Create(NIL);
Smtp.Host := sMX; SMTP.ReadTimeout:=5000;
try Smtp.Connect(5000) except
on E:Exception do begin Smtp.Free; Msg.Free; Exit; end;
end;
if not Smtp.Connected then begin Smtp.Free; Msg.Free; Exit; end;
try Smtp.Send(Msg) except
on E:Exception do begin Smtp.Disconnect; Smtp.Free; Msg.Free; Exit; end;
end;
Smtp.Disconnect; Smtp.Free; Msg.Free;
Result := true;
end;
function TEMAIL.GetMxList(dns,dmn:string):TstringList;
var k: Integer; IdDNS:TIdDnsResolver;
begin
Result := TstringList.Create;
IdDNS := TIdDnsResolver.Create(NIL);
if dns='' then dns := '202.102.128.68';
IdDNS.Host := dns;
IdDns.QueryRecords := [qtMX];
try IdDns.Resolve(dmn);
IdDns.Active;
for k := 0 to IdDns.QueryResult.Count-1 do if IdDns.QueryResult[k] IS TMxRecord then Result.Add(TMXRecord(IdDns.QueryResult[k]).ExchangeServer);
finally IdDns.Free;
end;
end;
function TEMAIL.NamelessEMS(vto,vsub:string;vbody:tstringlist):boolean;
begin
Result:=EMS(vto,'ems@ems.com','EMS',vsub,vbody);
end;
Initialization
EMAIL := TEMAIL.Create;
end.
---------------------------
Debugger Exception Notification
---------------------------
Project SfMail.exe raised exception class EIdSMTPReplyError with message 'authentication is required,mx13,wKjANLArSgCdPH9FyPaWGg==.32169S3 1165966493
'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
unit teml; interface
uses Windows,Classes,Sysutils,Dialogs,
IdSMTP,IdMessage,IdDNSResolver;
type TEMAIL=class(TObject)
private
function GetMxList(dns,dmn:string):TstringList;
function EmailAddrTest(a:string):boolean;
function EmailGetDomain(a:string):string;
function EmailGetName(a:string):string;
public
function EMS(vto,vfrom,vname,vsub:string;vbody:TstringList):boolean;
function NamelessEMS(vto,vsub:string;vbody:tstringlist):boolean;
end;
var EMAIL:TEMAIL;
implementation
function TEMAIL.EmailAddrTest(a:string):boolean;
var s:string; k,n,p:INTEGER;
begin
Result := false; if length(a)<5 then exit;
p := pos('@',a); if (p=0)or(p=length(a))or(p=1) then exit;
n := 0;
for k := 1 to length(a) do if a[k]='@' then inc;
if n<>1 then exit;
Result := true;
end;
function TEMAIL.EmailGetDomain(a:string):string;
var p:INTEGER;
begin
Result := '';
if not EmailAddrTest(a) then exit;
p := pos('@',a);
Result := COPY(a,p+1,Length(a)-p);
end;
function TEMAIL.EmailGetName(a:string):string;
var p:INTEGER;
begin
Result := '';
if not EmailAddrTest(a) then Exit;
p := POS('@',a);
Result := COPY(a,1,p-1);
end;
function TEMAIL.EMS(vto,vfrom,vname,vsub:string;vbody:TstringList):boolean;
var Smtp:TIdSmtp;
Msg:TIdMessage;
s,sMX,sDomain:string; k,m,p:INTEGER;
MX:TstringList;
begin
Result := false;
if not (EmailAddrTest(vto) and EmailAddrTest(vfrom)) then Exit;
sDomain:=EmailGetDomain(vto);
if sDomain='' then Exit;
MX := GetMxList('',sDomain);
if MX.Count<1 then begin MX.Free; end;
sMX := MX[0]; MX.Free;
Msg := TIdMessage.Create(NIL);
Msg.Subject := vsub;
Msg.Body.Addstrings(vbody);
Msg.Recipients.EMailAddresses := vto;
Msg.From.Address := vfrom;
Msg.From.Name := vname;
Smtp := TIdSmtp.Create(NIL);
Smtp.Host := sMX; SMTP.ReadTimeout:=5000;
try Smtp.Connect(5000) except
on E:Exception do begin Smtp.Free; Msg.Free; Exit; end;
end;
if not Smtp.Connected then begin Smtp.Free; Msg.Free; Exit; end;
try Smtp.Send(Msg) except
on E:Exception do begin Smtp.Disconnect; Smtp.Free; Msg.Free; Exit; end;
end;
Smtp.Disconnect; Smtp.Free; Msg.Free;
Result := true;
end;
function TEMAIL.GetMxList(dns,dmn:string):TstringList;
var k: Integer; IdDNS:TIdDnsResolver;
begin
Result := TstringList.Create;
IdDNS := TIdDnsResolver.Create(NIL);
if dns='' then dns := '202.102.128.68';
IdDNS.Host := dns;
IdDns.QueryRecords := [qtMX];
try IdDns.Resolve(dmn);
IdDns.Active;
for k := 0 to IdDns.QueryResult.Count-1 do if IdDns.QueryResult[k] IS TMxRecord then Result.Add(TMXRecord(IdDns.QueryResult[k]).ExchangeServer);
finally IdDns.Free;
end;
end;
function TEMAIL.NamelessEMS(vto,vsub:string;vbody:tstringlist):boolean;
begin
Result:=EMS(vto,'ems@ems.com','EMS',vsub,vbody);
end;
Initialization
EMAIL := TEMAIL.Create;
end.