?? smtp.h
字號:
// SMTP.h: interface for the CSMTP class.
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SMTP_H__55DE48CB_BEA4_11D1_870E_444553540000__INCLUDED_)
#define AFX_SMTP_H__55DE48CB_BEA4_11D1_870E_444553540000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <afxsock.h>
#include "MailMessage.h"
// SMTP服務器標準端口號
#define SMTP_PORT 25
// 定義接收緩沖區大小
#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();
// 連接是阻塞式的,因此要提供取消通信的方法
void Cancel();
private:
// 處理獲得的回應信息
BOOL get_response( UINT response_expected );
// 處理郵件正文
CString cook_body( CMailMessage* msg );
CString m_sError;
BOOL m_bConnected;
UINT m_nPort;
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是最后一個元素
LAST_RESPONSE
};
TCHAR *response_buf;
static response_code response_table[];
};
#endif // !defined(AFX_SMTP_H__55DE48CB_BEA4_11D1_870E_444553540000__INCLUDED_)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -