Refactored: More information hiding
[TortoiseGit.git] / src / Utils / HwSMTP.h
blob981fd0dde3e5eae4be62f6d08bde0cd818614404
1 // HwSMTP.h: interface for the CHwSMTP class.
2 //
3 //////////////////////////////////////////////////////////////////////
5 /*******************************************************************
6 ˵Ã÷
7 1¡¢ÕâÊÇÎÒ×Ô¼ºÐ´µÄÒ»¸öÀûÓÃSMTP·þÎñÆ÷·¢ËÍÓʼþµÄÀ࣬¿ÉÒÔʵÏÖ¸½¼þµÄ
8 ·¢ËÍ¡£
9 2¡¢ÔÚ InitInstance() º¯Êýµ÷ÓÃ
10 if (!AfxSocketInit())
12 AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
13 return FALSE;
15 ÔÚ ExitInstance () Öе÷Óà ::WSACleanup ();
16 *******************************************************************/
18 /****************************************************************************************************************
19 Ͷ¸å˵Ã÷£º
20 ****************************************************************************************************************/
21 #define NOTE_SpeedPostMail \
22 _T("\
23 ¡¾Èí¼þÃû³Æ¡¿\r\n\
24 ÎÞÐëSMTP·þÎñÆ÷ÖÐתֱ½Ó½«E-Mailµç×ÓÓʼþ·¢Ë͵½¶Ô·½ÓÊÏä\r\n\
25 ¡¾°æ ±¾¡¿\r\n\
26 1.0.0\r\n\
27 ¡¾²Ù×÷ϵͳ¡¿\r\n\
28 Windows ×ÀÃæϵÁÐ\r\n\
29 ¡¾×÷ Õß¡¿\r\n\
30 лºìΰ ¡¤ chrys ¡¤ chrys@163.com ¡¤ http://www.viction.net\r\n\
31 ¡¾Èí¼þ˵Ã÷¡¿\r\n\
32 ´ó¼ÒÒ»¶¨ÊìϤFoxmailÖеġ°ÌØ¿ìרµÝ¡±£¬ËüÄÜÖ±½Ó½«Óʼþ·¢Ë͵½¶Ô·½µÄÓʼþ·þÎñÆ÷ÖУ¬¶ø²»ÐèÒª¾­¹ýSMTP·þÎñÆ÷ÖÐת£¬\
33 ±¾´úÂ뽫ÏòÄãÆÊÎö¡°ÌØ¿ìרµÝ¡±·¢Ë͵ç×ÓÓʼþµÄ·½·¨¡£´úÂëÖÐÌṩÁËÍø¿¨ÐÅÏ¢»ñÈ¡À࣬¿ÉÒÔ»ñÈ¡±¾»úIPµØÖ·¡¢×ÓÍøÑÚÂë¡¢DNS¡¢\
34 Wins¡¢Íø¿¨MACµØÖ·µÈÏà¹ØÐÅÏ¢£»»¹ÌṩÁËSMTPЭÒé½âÎöÀ࣬¸ÃÀàʵÏÖÁËSMTP¿Í»§¶Ë¹¦ÄܵÄʵÏÖÀ࣬ʵÏÖµç×ÓÓʼþÊÕ·¢£»Base64±àÂëʵÏÖ\
35 ÁË×Ö·û±àÂëµÄ·½·¨¡£\r\n\
36 Äã¿ÉÒÔÈÎÒâÐ޸ĸ´ÖƱ¾´úÂ룬µ«Çë±£ÁôÕâ¶ÎÎÄ×Ö²»ÒªÐ޸ġ£\r\n\
37 Ï£ÍûÎÒÄÜΪÖйúµÄÈí¼þÐÐÒµ¾¡Ò»·Ý±¡Á¦£¡\r\n\
38 ¡¾¿ª·¢ÈÕÆÚ¡¿\r\n\
39 2008-11-23 3:54\r\n")
41 #include <afxsock.h>
43 #if !defined(AFX_HwSMTP_H__633A52B7_1CBE_41D7_BDA3_188D98D692AF__INCLUDED_)
44 #define AFX_HwSMTP_H__633A52B7_1CBE_41D7_BDA3_188D98D692AF__INCLUDED_
46 #if _MSC_VER > 1000
47 #pragma once
48 #endif // _MSC_VER > 1000
50 class CHwSMTP
52 public:
53 CString GetLastErrorText();
54 BOOL SendEmail (
55 LPCTSTR lpszSmtpSrvHost,
56 LPCTSTR lpszUserName,
57 LPCTSTR lpszPasswd,
58 BOOL bMustAuth,
59 LPCTSTR lpszAddrFrom,
60 LPCTSTR lpszAddrTo,
61 LPCTSTR lpszSubject,
62 LPCTSTR lpszBody,
63 LPCTSTR lpszCharSet, // ×Ö·û¼¯ÀàÐÍ£¬ÀýÈ磺·±ÌåÖÐÎÄÕâÀïÓ¦ÊäÈë"big5"£¬¼òÌåÖÐÎÄʱÊäÈë"gb2312"
64 CStringArray *pStrAryAttach=NULL,
65 LPCTSTR pStrAryCC=NULL,
66 UINT nSmtpSrvPort=25,
67 LPCTSTR pSend = NULL,
68 LPCTSTR pToList = NULL
70 BOOL SendSpeedEmail
72 LPCTSTR lpszAddrFrom,
73 LPCTSTR lpszAddrTo,
74 LPCTSTR lpszSubject,
75 LPCTSTR lpszBody,
76 LPCTSTR lpszCharSet, // ×Ö·û¼¯ÀàÐÍ£¬ÀýÈ磺·±ÌåÖÐÎÄÕâÀïÓ¦ÊäÈë"big5"£¬¼òÌåÖÐÎÄʱÊäÈë"gb2312"
77 CStringArray *pStrAryAttach=NULL,
78 LPCTSTR pStrAryCC=NULL,
79 UINT nSmtpSrvPort=25,
80 LPCTSTR pSend = NULL
82 CHwSMTP();
83 virtual ~CHwSMTP();
85 protected:
86 CString GetServerAddress(CString &email);
87 void GetNameAddress(CString &in, CString &name,CString &address);
89 private:
90 BOOL SendSubject();
91 CString m_StrCC;
92 BOOL SendHead();
93 BOOL auth();
94 BOOL SendEmail();
95 BOOL Send ( CString &data );
96 BOOL SendBuffer(char *buffer,int size=-1);
97 BOOL GetResponse( LPCTSTR lpszVerifyCode, int *pnCode=NULL );
98 BOOL m_bConnected;
99 CSocket m_SendSock;
100 CStringArray m_StrAryAttach;
101 CString m_csSmtpSrvHost;
102 CString m_csUserName;
103 CString m_csPasswd;
104 CString m_csAddrFrom;
105 CString m_csAddrTo;
106 CString m_csFromName;
107 CString m_csReceiverName;
108 CString m_csSubject;
109 CString m_csBody;
110 CString m_csSender;
111 CString m_csToList;
113 private:
114 BOOL m_bMustAuth;
115 UINT m_nSmtpSrvPort;
116 CString m_csCharSet;
118 CString m_csLastError;
119 BOOL SendOnAttach(LPCTSTR lpszFileName);
120 BOOL SendAttach();
121 BOOL SendBody();
122 CString m_csMIMEContentType;
123 CString m_csPartBoundary;
124 CString m_csNoMIMEText;
128 BOOL SendEmail (
129 BOOL bViaThreadSend, // FALSE - Ö±½Ó·¢ËÍ£¬ TRUE - ÔÚÏß³ÌÖз¢ËÍ£¬·µ»ØÏ߳̾ä±ú
130 LPCTSTR lpszSmtpSrvHost, // SMTP ·þÎñÆ÷£¬È磺smtp.21cn.com
131 LPCTSTR lpszUserName, // µÇ¼·þÎñÆ÷ÑéÖ¤Éí·ÝµÄÓû§Ãû
132 LPCTSTR lpszPasswd, // µÇ¼·þÎñÆ÷ÑéÖ¤Éí·ÝµÄÃÜÂë
133 BOOL bMustAuth, // SMTP ·þÎñÆ÷ÐèÒªÉí·ÝÑéÖ¤
134 LPCTSTR lpszAddrFrom, // ·¢ËÍÕß E-Mail µØÖ·
135 LPCTSTR lpszAddrTo, // ½ÓÊÕÕßµÄ E-Mail µØÖ·
136 LPCTSTR lpszFromName, // ·¢ËÍÕßµÄÃû×Ö£¬ÀýÈ磺лºìΰ
137 LPCTSTR lpszReceiverName, // ½ÓÊÕÕßµÄÃû×Ö£¬ÀýÈ磺ÕÅ·É
138 LPCTSTR lpszSubject, // ÓʼþÖ÷Ìâ
139 LPCTSTR lpszBody, // ÓʼþÄÚÈÝ
140 LPCTSTR lpszCharSet=NULL, // ×Ö·û¼¯ÀàÐÍ£¬ÀýÈ磺·±ÌåÖÐÎÄÕâÀïÓ¦ÊäÈë"big5"£¬¼òÌåÖÐÎÄʱÊäÈë"gb2312"
141 CStringArray *pStrAryAttach=NULL, // ¸½¼þÎļþ·¾¶£¬¿ÉÒÔ¶à¸ö
142 LPCTSTR pStrAryCC=NULL, // ³­ËÍ E-Mail µØÖ·£¬¿ÉÒÔ¶à¸ö
143 UINT nSmtpSrvPort=25, // SMTP ·þÎñÆ÷µÄ TCP ¶Ë¿ÚºÅ
144 LPCTSTR pSend = NULL,
145 LPCTSTR ToList = NULL
149 void EndOfSMTP ();
151 #endif // !defined(AFX_HwSMTP_H__633A52B7_1CBE_41D7_BDA3_188D98D692AF__INCLUDED_)