-
Notifications
You must be signed in to change notification settings - Fork 13
/
SMTPClientService.cpp
50 lines (37 loc) · 2.25 KB
/
SMTPClientService.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "SMTPClientService.h"
SMTPClientService::SMTPClientService(unsigned int nRecvSecTimeout) : ClientService(nRecvSecTimeout) {
this->nDefaultPort = SMTP_CLIENT_SERVICE_DEFAULT_PORT;
this->nDefaultPortSSL = SMTP_CLIENT_SERVICE_SSL_DEFAULT_PORT;
this->nDefaultPortTLS = SMTP_CLIENT_SERVICE_TLS_DEFAULT_PORT;
this->sEndCommandLine = SMTP_CLIENT_SERVICE_END_COMMAND_LINE;
this->bReceiveOnConnect = true;
}
bool SMTPClientService::authCryptographicSecurity() {
this->bAuthCryptographicSecurity = true;
return this->bAuthCryptographicSecurity;
}
bool SMTPClientService::authLoginUser() {
vector< pair<string, string> > * oStringTokens = new vector< pair<string, string> >();
string sRecvSocketData = GLOBAL_STRING_EMPTY;
this->bAuthLoginUser = false;
if (FString::trim(this->sLoginUsername).length() > 0) {
if (this->sendSocketData(SMTP_CLIENT_SERVICE_AUTH_COMMAND + this->getEndCommandLine())) {
sRecvSocketData = this->recvSocketData();
if (sRecvSocketData.find(SMTP_CLIENT_SERVICE_AUTH_ASK_CREDENTIALS_REPLY_CODE) != string::npos) {
oStringTokens->push_back(pair<string, string>(GLOBAL_STF_FILE_ENCODE_NOTATION_LOGIN_USERNAME, FCrypt::cryptBase64(this->sLoginUsername)));
if (this->sendSocketData(FString::replaceTokens(SMTP_CLIENT_SERVICE_AUTH_COMMAND_USER, oStringTokens) + this->getEndCommandLine())) {
sRecvSocketData = this->recvSocketData();
if (sRecvSocketData.find(SMTP_CLIENT_SERVICE_AUTH_ASK_CREDENTIALS_REPLY_CODE) != string::npos) {
oStringTokens->clear();
oStringTokens->push_back(pair<string, string>(GLOBAL_STF_FILE_ENCODE_NOTATION_LOGIN_PASSWORD, FCrypt::cryptBase64(this->sLoginPassword)));
if (this->sendSocketData(FString::replaceTokens(SMTP_CLIENT_SERVICE_AUTH_COMMAND_PASSWORD, oStringTokens) + this->getEndCommandLine())) {
sRecvSocketData = this->recvSocketData();
if (sRecvSocketData.find(SMTP_CLIENT_SERVICE_AUTH_SUCCESS_REPLY_CODE) != string::npos) this->bAuthLoginUser = true;
}
}
}
}
}
}
return this->bAuthLoginUser;
}