大家来看看这个EMAIL发送程序错在那里?(200分)

  • 主题发起人 主题发起人 agezhu
  • 开始时间 开始时间
A

agezhu

Unregistered / Unconfirmed
GUEST, unregistred user!
function temail(n:string;p:string):integer;
var
s2,i:string;
sbuf1:array[0..512] of char;
x,t:integer;
begin
x:=1;
t:=0;

s1:='EHLO smtp.hacker.com'+crlf;
strcopy(sbuf,pchar(s1));
send(fsocket,sbuf,strlen(sbuf),msg_dontroute);

repeat
recv(fsocket,sbuf1,400,0);
s2:=string(sbuf1);
tt(s2);
s2:=copy(s2,0,3);


if (s2='250')or(s2='220')or(S2='235') then
begin
case x of
1:s1:='AUTH LOGIN'+crlf;
4:s1:='mail from:<getoicq@sohu.com>'+crlf;
5:s1:='rcpt to:<agezhu@sohu.com>'+crlf;
6:s1:='data'+crlf;
8:s1:='quit'+crlf;
end;
end
else if s2='334' then
begin
case x of
2:s1:=n+crlf;
3:s1:=p+crlf;
end;
end
else if s2='354' then
s1:='from:<getoicq@21cn.com>'+crlf
+'to:<agezhu@sohu.com>'+crlf
+'subject:qq2001'+crlf
+'test is good'+crlf
+crlf
+'.'+crlf

else
break;


strcopy(sbuf,pchar(s1));
send(fsocket,sbuf,strlen(sbuf),msg_dontroute);
t:=t+1;
inc(x);

until (x>7)or (t>15)
end;



procedure TForm1.Button1Click(Sender: TObject);
var
err,y:integer;
n,p:string;
begin
err:=wsastartup($0101,wsadata);
if err<>0 then tt('1');
fsocket:=socket(pf_inet,sock_stream,ipproto_ip);
fhost:=edit3.Text;
fport:=25;
sockaddrin.sin_addr.s_addr:=inet_addr(pchar(fhost));
sockaddrin.sin_family := pf_inet;
sockaddrin.sin_port :=htons(fport);
err:=connect(fsocket,sockaddrin, sizeof(sockaddrin));
if err<>0 then
tt('2')
else
begin
n:=edit1.text;
p:=edit2.text;
n:=EncodeBase64(n);
p:=EncodeBase64(p);
temail(n,p);
end;
err:=closesocket(fsocket);
err:=wsacleanup;
end;

 
老大没法调试tt(s2);是什么东东
 
tt(s2)是一个调用的函数,不用管它。
 
后退
顶部