我要一个 SMTP 发送邮件的例子
查过以前的贴子 大多都不能用
望谁能给我一个 已经验证过的例子
希望大家支持 但不要去给我转贴那些没有验证过的东西
查过以前的贴子 大多都不能用
望谁能给我一个 已经验证过的例子
希望大家支持 但不要去给我转贴那些没有验证过的东西
解决方案 »
- delphi制作的程序在左面右下角弹出提示
- 长假,我再散
- 如何在stringGrid的一列单元格设为下拉框
- 请帮忙看一下!
- 请教透明panel的制作方法
- 为什么我的FORM里放了一张图片,当我打开form的时候,总是先显示灰色的form,然后再显示图片,有滞后的感觉
- 我是程序精品室版主,我们正在组建团队开发训练和实例开发,欢迎大家参与.
- 我安装ehlib26倥件时,找不到.pas文件为什么?
- 高分::::屏幕取词,全部判断,有类似词库中的词一律屏蔽掉.请问怎么实现?怎么实现最快?
- 高分求教,我的窗口嵌入到IE的工具栏中,
- 高分求教QuickShape的用法(关于报表中绘制线条的问题)。不够再加分!
- 请看bde一错误!!
不过这段时间我不能上网,你得等!
TPop=class (TComponent)
public
UserName:string;//Email帐户名
PassWord:string; //Email口令
ReceText:Pchar; //server端收到的字符串
PopState:SessionState;
//pop状态:
init or authorization or transaction or update
MsgCount:integer; //邮件总数
SizeCount:integer; //邮件总大小
ReplyString:string;//服务器端发送的应答信息
DeleIndex:byte;//用户要删的邮件序号
ListIndex:byte;//list方法 的参数:
用户要列出的序号为listindex的邮件信息
RetrIndex:byte;//retr方法的参数:
用户要取序号为retrindex的邮件
TopIndex:byte; //top方法的参数
QuitFlag:boolean;//用户如果通过quit命断连则此变量为true;
反之(此时要把f_dele都置回0)
OldMsgCount:integer;//旧邮件数:Last 命令返回
//邮件头的各个域
HMsgId:string;
HReplyTo:string;
HDate:string;
HFrom:string;
HTo:string;
HSubject:string;
HMIME_Ver:real;
HContent_Type:string;
HContent_Transfer_Encoding:string;
HText:string;
//所有POP3服务器必须支持的命令
procedure user;
function pass:boolean;
procedure stat;
procedure dele;
procedure list;
procedure retr;
procedure noop;
procedure rset;
procedure aquit;
procedure tquit;
//扩展的可选择实现的POP3 命令
procedure top;
procedure last;
procedure apop;
procedure uidl;
end;
---- 1. 建立连接 ---- 我们可以看到利用了Tclientsocket后客户端请求建立连接只需下面的代码。 with ClientSocket do
begin
Host := Server;
Active := True;
end;
---- 服务器端利用TserverSocket,一直在侦听110端口,若客户端有连接请求,则ServerSocketAccept事件会被激活,建立起连接。 procedure TMyForm.ServerSocketAccept(Sender: TObject;
Socket: TCustomWinSocket);
begin
Statusbar1.Panels[0].Text :=
'连接到 ' + Socket.RemoteAddress;
//pop对象初始化
pop:=TPop.Create(nil);
pop.PopState:=init;
pop.LoginResult:=false;
pop.QuitFlag:=false;
ServerSocket.Socket.Connections[0]
.sendtext('+OK ibonc pop3 server is ready'+crlf);end;
---- 2. 通信 ---- 服务器端收到客户端发来的信息,则会激活ServerSocketClientRead事件,通过ServerSocket的Socket.ReceiveText可以得到信息的内容。 procedure TMyForm.ServerSocketClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var temp_command :string;
//存放接收到的命令行,并做去crlf的处理
begin
temp_command:=Socket.ReceiveText;
//to remove the crlf in command line
temp_command:=trim(copy(temp_command,1,
pos(crlf,temp_command)-1));
pop.ReceText:=pchar(temp_command);
if pop.popstate=init then
if strLIComp(pop.ReceText,'user ',5)=0 then
pop.user
else
ServerSocket.Socket.Connections[0]
.sendtext('-ERR user name please')
else if pop.popstate=authorization then
begin
if strLIComp(pop.ReceText,'pass ',5)=0 then
pop.pass
else if strIComp(pop.ReceText,'quit')=0 then
pop.aquit
else
ServerSocket.Socket.Connections[0]
.sendtext('-ERR pass word please');
end
else if pop.popstate=transaction then
begin
if strIComp(pop.ReceText,'stat')=0 then
pop.stat
else if strLIComp(pop.ReceText,'dele ',5)=0 then
pop.dele
else if strLIComp(pop.ReceText,'list',4)=0 then
pop.list
else if strLIComp(pop.ReceText,'retr ',5)=0 then
pop.retr
else if strIComp(pop.ReceText,'noop')=0 then
pop.noop
else if strIComp(pop.ReceText,'rset')=0 then
pop.rset
else if strIComp(pop.ReceText,'quit')=0 then
pop.tquit
else if strIComp(pop.ReceText,'last')=0 then
pop.last
else if strLIComp(pop.ReceText, 'apop ',5)=0 then
pop.apop
else if strLIComp(pop.ReceText, 'uidl ',5)=0 then
pop.uidl
else
ServerSocket.socket.connections[0]
.sendtext('-ERR no such command yet'+crlf);
end
end;
---- 3. 关闭连接 procedure TMyForm.ServerSocket
ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
ServerSocket.Active := False;
//如果client端没有通过quit 命令断连,
则在断连时要把那些f_dele置为0
if pop.QuitFlag=False then
begin
MyForm.query11.Close;
MyForm.query11.Params[0].Asstring:=pop.UserName;
MyForm.query11.prepare;
MyForm.query11.execsql;
end;
end;
http://www.nevrona.com/Indy/index.html