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