smtp-client
SMTP Client C Library
test_cpp_wrapper.cpp File Reference

Test the smtp-client CPP wrapper. More...

#include <err.h>
#include <SMTPMail.h>
+ Include dependency graph for test_cpp_wrapper.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Test the smtp-client CPP wrapper.

Author
James Humphrey (mail@.nosp@m.somn.nosp@m.isoft.nosp@m..com)
Version
1.00

Example program demonstrating how to use the CPP wrapper class.

This software has been placed into the public domain using CC0.

Definition in file test_cpp_wrapper.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main program entry point for the example smtp-client CPP class wrapper.

Parameters
[in]argcNumber of arguments in argv.
[in]argvString array containing the program name and any optional parameters described above.
Return values
0Email has been sent.
1An error occurred while sending email. Although unlikely, an email can still get sent even after returning with this error code.

Definition at line 25 of file test_cpp_wrapper.cpp.

References SMTPMail::address_add(), SMTPMail::auth(), SMTPMail::close(), SMTPMail::header_add(), SMTPMail::mail(), SMTPMail::open(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, SMTP_AUTH_NONE, SMTP_DEBUG, SMTP_SECURITY_NONE, and SMTPMailException::what().

25  {
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 }
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
void mail(const char *const body)
Definition: SMTPMail.cpp:49
void close(void)
Definition: SMTPMail.cpp:54
void header_add(const char *const key, const char *const value)
Definition: SMTPMail.cpp:68
+ Here is the call graph for this function: