smtp-client
SMTP Client C Library
test_cpp_wrapper.cpp
Go to the documentation of this file.
1 
11 #include <err.h>
12 
13 #include <SMTPMail.h>
14 
25 int main(int argc, char *argv[]){
26  SMTPMail *mail;
27 
28  mail = new SMTPMail();
29  try{
30  mail->open("localhost", "25", SMTP_SECURITY_NONE, SMTP_DEBUG, NULL);
31  mail->auth(SMTP_AUTH_NONE, NULL, NULL);
33  "mail@somnisoft.com",
34  "From Address");
36  "mail@somnisoft.com",
37  "To Address");
38  mail->header_add("Subject", "Test email (SMTPMail)");
39  mail->mail("Email sent using CPP SMTPMail class");
40  mail->close();
41  }
42  catch(SMTPMailException sme){
43  errx(1, "Failed to send email: %s\n", sme.what());
44  }
45  delete mail;
46 
47  return 0;
48 }
49 
void auth(enum smtp_authentication_method auth_method, const char *const user, const char *const pass)
Definition: SMTPMail.cpp:42
void address_add(enum smtp_address_type type, const char *const email, const char *const name)
Definition: SMTPMail.cpp:78
void open(const char *const server, const char *const port, enum smtp_connection_security connection_security, enum smtp_flag flags, const char *const cafile)
Definition: SMTPMail.cpp:28
virtual const char *const what()
Definition: SMTPMail.cpp:18
int main(int argc, char *argv[])
void mail(const char *const body)
Definition: SMTPMail.cpp:49
void close(void)
Definition: SMTPMail.cpp:54
SMTPMail class wrapper for smtp-client library.
void header_add(const char *const key, const char *const value)
Definition: SMTPMail.cpp:68