⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smtp.h

📁 通讯录程序
💻 H
字号:
// SMTP.h: interface for the CSMTP class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SMTP_H__35206EC9_0725_11D5_B854_0050BAD0985B__INCLUDED_)
#define AFX_SMTP_H__35206EC9_0725_11D5_B854_0050BAD0985B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <afxsock.h>
#include "MailMessage.h"

#define SMTP_PORT 25	               //标准SMTP服务器端口号	
#define RESPONSE_BUFFER_SIZE 1024      //用于接受响应信息的缓冲区大小
//类:连接服务器、发送数据、接受响应、断开连接等
class CSMTP  
{
public:
	CSMTP( LPCTSTR szSMTPServerName, UINT nPort = SMTP_PORT );
	virtual ~CSMTP();

	void SetServerProperties( LPCTSTR szSMTPServerName, UINT nPort = SMTP_PORT );
	CString GetLastError();
	UINT GetPort();
	BOOL Disconnect();
	BOOL Connect();
	virtual BOOL FormatMailMessage( CMailMessage* msg );
	BOOL SendMessage( CMailMessage* msg );
	CString GetServerHostName();

private:
	BOOL get_response( UINT response_expected );
	CString cook_body( CMailMessage* msg );

	CString m_sError;        //关于错误信息
	BOOL m_bConnected;       //连接判断
	UINT m_nPort;            //SMTP服务器端口号
	CString m_sSMTPServerHostName;   //SMTP服务器的主机名
	CSocket m_wsSMTPServer;     //套接字对象

protected:
	virtual BOOL transmit_message( CMailMessage* msg );

	struct response_code
	{
		UINT nResponse;	
		TCHAR* sMessage;
	};
//枚举了可能出现的错误
	enum eResponse
	{
		GENERIC_SUCCESS = 0,
		CONNECT_SUCCESS,
		DATA_SUCCESS,
		QUIT_SUCCESS,
		LAST_RESPONSE
	};
	TCHAR *response_buf;
	static response_code response_table[];
};

#endif // !defined(AFX_SMTP_H__35206EC9_0725_11D5_B854_0050BAD0985B__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -