设为首页 加入收藏

TOP

POP3协议封装类
2014-11-23 20:00:31 来源: 作者: 【 】 浏览:11
Tags:POP3 协议 封装

目前互连网上,EMAIL的使用是越来越广泛了。在所有的TCP连接线路中,大概有一半的线路是用来收发EMAIL的。因此,许多网络应用程序要想离开POP3协议是不可能的。

而且,很多EMAIL系统都是使用SMTP协议来作为发送协议,而POP3协议来作为接受协议。关于这2个协议的许多资料,你可以看一下RCF821(关于SMTP的)和RCF1225(关于POP3的)。虽然在WINDOWS操作系统中,有一个叫MAPI应用程序是来管理EMAIL的,但是它的功能还不够强大,不足以直接处理一些EMAIL服务。所以,我写了一个有关于POP3协议的C++类,在这个类中我还使用了CSocket作为一个类成员(这好象有点不可想象),这样的话呢,我们可以在连接的时候使用它。并且,该POP类使用的一些功能类似于POP3协议中的一些命令。下面就代码:

/*--------------------------------------------------------------------

Pop.h : main header file for the POP application

-----------------------------------------------------------------------*/

#if !defined(AFX_POP_H__A44B38B6_697C_11D1_881E_00001C302581__INCLUDED_)

#define AFX_POP_H__A44B38B6_697C_11D1_881E_00001C302581__INCLUDED_

#define CONNECTION_CHECK 0

#define USER_CHECK 1

#define PASSWORD_CHECK 2

#define QUIT_CHECK 3

#define DELETE_CHECK 4

#define RSET_CHECK 5

#define STAT_CHECK 6

#define NOOP_CHECK 7

#define LIST_CHECK 8

#define RETR_CHECK 9

/////////////////////////////////////////////////////////////////////////////

class CPop

{

public:

BOOL List();

CWordArray m_SizeOfMsg;

CString GetErrorMessage(); // If there is any error this will return it method

CString GetPassword(); // Getting Password stored in class

void SetPassword(CString& Password); // Setting Password in class

CString GetUser(); // Getting user name stored in class

void SetUser(CString& User); // Setting user name in class

CString GetHost(); // Getting Host name (email server name) stored in class

void SetHost(CString& Host); // Setting Host name (email server name) in class

BOOL Connect(); // Connecting to email server

int GetTotalMailSize(); // it returns the Total Mail Size

int GetNumberOfMails(); // It return the number of mails

CString GetMsgContents();

BOOL Statistics(); // issue the STAT command on email server

BOOL Retrieve(int MsgNumber); // Getting any particular mail message

BOOL Reset(); // issue the reset command on email server

int GetMessageSize(int MsgNumber); // Return a size of any particular mail

BOOL Noop();

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇简单邮件传输协议SMTP封装类 下一篇利用ATL(ActiveX模板库)创建Act..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: