F
FAQ007
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么不能发邮件!!!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,winsock, StdCtrls;
const
crlf=#13#10;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
err:integer;
wsadata:twsadata;
fsocket,fport,step:integer;
sockaddrin:tsockaddrin;
fhost,s1:string;
sbuf:array[0..1024] of char;
implementation
{$R *.dfm}
procedure mailsend;
begin
err:=recv(fsocket,sbuf,400,0);
showmessage(sbuf);
s1:=strpas(sbuf);
inc(step);
case step of
1:s1:='helo smtp.sina.com.cn'+crlf;
2:s1:='mail from: <lanxix825@sina.com>'+crlf;
3:s1:='rcpt to: <lanxix825@sina.com>'+crlf;
4:s1:='data'+crlf;
5:s1:='from:"lanxix825"<www.sina.com.cn>'+crlf
+'to:"lanxix825"<www.sina.com.cn>'+crlf
+'subject:come on now.'+crlf+crlf
+'hello!'+crlf
+'.'+crlf;
6:s1:='quit'+crlf;
else
step:=0;
end;
strcopy(sbuf,pchar(s1));
err:=send(fsocket,sbuf,strlen(sbuf),msg_dontroute);
end;
procedure sendpass;
begin
err:=wsastartup($0101,wsadata);
showmessage(inttostr(err));
fsocket := socket(pf_inet, sock_stream,ipproto_ip);
fhost:='stmp.sina.com.cn';
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));
step:=0;
repeat
mailsend;
until step=0;
err:=closesocket(fsocket);
err:=wsacleanup;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
sendpass;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,winsock, StdCtrls;
const
crlf=#13#10;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
err:integer;
wsadata:twsadata;
fsocket,fport,step:integer;
sockaddrin:tsockaddrin;
fhost,s1:string;
sbuf:array[0..1024] of char;
implementation
{$R *.dfm}
procedure mailsend;
begin
err:=recv(fsocket,sbuf,400,0);
showmessage(sbuf);
s1:=strpas(sbuf);
inc(step);
case step of
1:s1:='helo smtp.sina.com.cn'+crlf;
2:s1:='mail from: <lanxix825@sina.com>'+crlf;
3:s1:='rcpt to: <lanxix825@sina.com>'+crlf;
4:s1:='data'+crlf;
5:s1:='from:"lanxix825"<www.sina.com.cn>'+crlf
+'to:"lanxix825"<www.sina.com.cn>'+crlf
+'subject:come on now.'+crlf+crlf
+'hello!'+crlf
+'.'+crlf;
6:s1:='quit'+crlf;
else
step:=0;
end;
strcopy(sbuf,pchar(s1));
err:=send(fsocket,sbuf,strlen(sbuf),msg_dontroute);
end;
procedure sendpass;
begin
err:=wsastartup($0101,wsadata);
showmessage(inttostr(err));
fsocket := socket(pf_inet, sock_stream,ipproto_ip);
fhost:='stmp.sina.com.cn';
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));
step:=0;
repeat
mailsend;
until step=0;
err:=closesocket(fsocket);
err:=wsacleanup;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
sendpass;
end;
end.