SMTP.h
Upload User: tjsct008
Upload Date: 2016-12-02
Package Size: 3750k
Code Size: 1k
Category:

WEB Mail

Development Platform:

Visual C++

  1. // SMTP.h: interface for the CSMTP class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_SMTP_H__14387B48_E339_4CC3_BD01_9BE6C6010E46__INCLUDED_)
  5. #define AFX_SMTP_H__14387B48_E339_4CC3_BD01_9BE6C6010E46__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include <afxsock.h>
  10. #include "MailMessage.h"
  11. #define SMTP_PORT 25
  12. #define RESPONSE_BUFFER_SIZE 1024
  13. class CSMTP  
  14. {
  15. public:
  16. CSMTP(LPCSTR szSMTPServerName,UINT nPort = SMTP_PORT);
  17. virtual ~CSMTP();
  18. CString GetLastError();
  19. UINT GetPort();
  20. BOOL DisConnect();
  21. BOOL Connect();
  22. virtual BOOL FormatMailMessage(CMailMessage * msg);
  23. BOOL SendMessage(CMailMessage * msg);
  24. CString GetServerHostName();
  25. private:
  26. BOOL get_response(UINT response_expect);
  27. CString cook_body(CMailMessage * pmg);
  28. CString m_sError;
  29. BOOL m_bConnected;
  30. UINT m_nPort;
  31. CString m_sSTMPServerHostName;
  32. CSocket m_wsSMTPServer;
  33. protected:
  34. virtual BOOL transmit_message(CMailMessage * msg);
  35. struct response_code
  36. {
  37. UINT nResponse;
  38. TCHAR * sMessage;
  39. };
  40. enum eResponse
  41. {
  42. GENERIC_SUCCESS = 0,
  43. CONNECT_SUCCESS,
  44. DATA_SUCCESS,
  45. QUIT_SUCCESS,
  46. LAST_RESPONSE
  47. };
  48. TCHAR * response_buf;
  49. static response_code response_table[];
  50. };
  51. #endif // !defined(AFX_SMTP_H__14387B48_E339_4CC3_BD01_9BE6C6010E46__INCLUDED_)