1 // CSmtp.h: interface for the Smtp class.
\r
3 //////////////////////////////////////////////////////////////////////
\r
5 #if !defined __CSMTP_H__
\r
10 #endif // _MSC_VER > 1000
\r
12 #include <winsock2.h>
\r
17 #pragma comment(lib, "ws2_32.lib")
\r
19 #pragma warning(push)
\r
20 #pragma warning(disable:4786)
\r
25 #define BUFFER_SIZE 10240 // SendData and RecvData buffers sizes
\r
26 #define DELAY_IN_MS 10 // delay between send and recv functions
\r
27 #define MSG_SIZE_IN_MB 5 // the maximum size of the message with all attachments
\r
29 const char BOUNDARY_TEXT[] = "__MESSAGE__ID__54yg6f6h6y456345";
\r
34 CSMTP_WSA_STARTUP = 100, // WSAGetLastError()
\r
39 CSMTP_WSA_GETHOSTBY_NAME_ADDR,
\r
40 CSMTP_WSA_INVALID_SOCKET,
\r
42 CSMTP_BAD_IPV4_ADDR,
\r
43 CSMTP_UNDEF_MSG_HEADER = 200,
\r
44 CSMTP_UNDEF_MAILFROM,
\r
45 CSMTP_UNDEF_SUBJECT,
\r
46 CSMTP_UNDEF_RECIPENTS,
\r
48 CSMTP_UNDEF_PASSWORD,
\r
49 CSMTP_UNDEF_RECIPENT_MAIL,
\r
50 CSMTP_COMMAND_MAIL_FROM = 300,
\r
52 CSMTP_COMMAND_AUTH_LOGIN,
\r
55 CSMTP_COMMAND_RCPT_TO,
\r
56 CSMTP_MSG_BODY_ERROR,
\r
57 CSMTP_CONNECTION_CLOSED = 400, // by server
\r
58 CSMTP_SERVER_NOT_READY, // remote server
\r
59 CSMTP_FILE_NOT_EXIST,
\r
61 CSMTP_BAD_LOGIN_PASS,
\r
62 CSMTP_UNDEF_XYZ_RESPOMSE,
\r
63 CSMTP_LACK_OF_MEMORY
\r
69 XPRIORITY_NORMAL = 3,
\r
78 bool AddRecipient(const char *email, const char *name=NULL);
\r
79 bool AddBCCRecipient(const char *email, const char *name=NULL);
\r
80 bool AddCCRecipient(const char *email, const char *name=NULL);
\r
81 bool AddAttachment(const char *path);
\r
82 const unsigned int GetBCCRecipientCount();
\r
83 const unsigned int GetCCRecipientCount();
\r
84 const unsigned int GetRecipientCount();
\r
85 const char* const GetLocalHostIP();
\r
86 const char* const GetLocalHostName();
\r
87 const char* const GetMessageBody();
\r
88 const char* const GetReplyTo();
\r
89 const char* const GetMailFrom();
\r
90 const char* const GetSenderName();
\r
91 const char* const GetSubject();
\r
92 const char* const GetXMailer();
\r
93 CSmptXPriority GetXPriority();
\r
94 CSmtpError GetLastError();
\r
96 void SetMessageBody(const char*);
\r
97 void SetSubject(const char*);
\r
98 void SetSenderName(const char*);
\r
99 void SetSenderMail(const char*);
\r
100 void SetReplyTo(const char*);
\r
101 void SetXMailer(const char*);
\r
102 void SetLogin(const char*);
\r
103 void SetPassword(const char*);
\r
104 void SetXPriority(CSmptXPriority);
\r
105 void SetSMTPServer(const char* server,const unsigned short port=0);
\r
108 CSmtpError m_oError;
\r
109 char* m_pcLocalHostName;
\r
110 char* m_pcMailFrom;
\r
111 char* m_pcNameFrom;
\r
118 char* m_pcPassword;
\r
119 char* m_pcSMTPSrvName;
\r
120 unsigned short m_iSMTPSrvPort;
\r
121 CSmptXPriority m_iXPriority;
\r
136 std::vector<Recipent> Recipients;
\r
137 std::vector<Recipent> CCRecipients;
\r
138 std::vector<Recipent> BCCRecipients;
\r
139 std::vector<std::string> Attachments;
\r
141 bool ReceiveData();
\r
143 bool FormatHeader(char*);
\r
144 int SmtpXYZdigits();
\r
145 SOCKET ConnectRemoteServer(const char* server, const unsigned short port=NULL);
\r
147 friend char* GetErrorText(CSmtpError);
\r
151 #pragma warning(pop)
\r
153 #endif // __CSMTP_H__
\r