Electroneum
Loading...
Searching...
No Matches
epee::net_utils::smtp Namespace Reference

Classes

class  smtp_client

Typedefs

typedef base64_from_binary< transform_width< const char *, 6, 8 > > base64_text

Functions

bool send_mail (const std::string &server, int port, const std::string &login, const std::string &pass, const std::string &from_email, const std::string &maillist, const std::string &subject, const std::string &body)
bool send_mail (const std::string &server, int port, const std::string &login, const std::string &pass, const std::string &from_addres, const std::string &from_name, const std::string &maillist, const std::string &subject, const std::string &mail_body)

Typedef Documentation

◆ base64_text

typedef base64_from_binary<transform_width<const char *,6,8> > epee::net_utils::smtp::base64_text

Definition at line 52 of file smtp.h.

Function Documentation

◆ send_mail() [1/2]

bool epee::net_utils::smtp::send_mail ( const std::string & server,
int port,
const std::string & login,
const std::string & pass,
const std::string & from_addres,
const std::string & from_name,
const std::string & maillist,
const std::string & subject,
const std::string & mail_body )
inline

Definition at line 40 of file smtp_helper.h.

41 {
42 net_utils::smtp::CSMTPClient smtp;
43
44 if ( !smtp.ServerConnect( server.c_str(), port ) )
45 {
46 LOG_PRINT("Reporting: Failed to connect to server " << server <<":"<< port, LOG_LEVEL_0);
47 return false;
48 }
49
50 if(login.size() && pass.size())
51 {
52 if ( !smtp.ServerLogin( login.c_str(), pass.c_str()) )
53 {
54 LOG_PRINT("Reporting: Failed to auth on server " << server <<":"<< port, LOG_LEVEL_0);
55 return false;
56
57 }
58 }
59
60 if ( !smtp.SendMessage( from_addres.c_str(),
61 from_name.c_str(),
62 maillist.c_str(),
63 subject.c_str(),
64 "bicycle-client",
65 (LPBYTE)mail_body.data(),
66 mail_body.size()))
67 {
68 char *szErrorText = smtp.GetLastErrorText();
69 if ( szErrorText )
70 {
71 LOG_PRINT("Failed to send message, error text: " << szErrorText, LOG_LEVEL_0);
72 }
73 else
74 {
75 LOG_PRINT("Failed to send message, error text: null", LOG_LEVEL_0);
76 }
77 return false;
78 }
79
80 smtp.ServerDisconnect();
81
82 return true;
83
84
85 }

◆ send_mail() [2/2]

bool epee::net_utils::smtp::send_mail ( const std::string & server,
int port,
const std::string & login,
const std::string & pass,
const std::string & from_email,
const std::string & maillist,
const std::string & subject,
const std::string & body )

Definition at line 166 of file smtp.h.

168 {
170 //smtp_client mailc("yoursmtpserver.com",25,"user@yourdomain.com","password");
171 //mailc.Send("from@yourdomain.com","to@somewhere.com","subject","Hello from C++ SMTP Client!");
172 smtp_client mailc(server,port,login,pass);
173 return mailc.Send(from_email,maillist,subject,body);
174 STD_TRY_CATCH("at send_mail", false);
175 }
#define STD_TRY_BEGIN()
#define STD_TRY_CATCH(where_, ret_val)
Here is the call graph for this function: