#include <iostream>
#include <jwsmtp/jwsmtp.h>
using std::cout;
using std::cin;
using std::string;
void Usage( ) {
cout << "jwSMTP library demo program\n"
"maildemo \n"
" e.g.\n"
" maildemo you@there.com me@here.com mail.here.com\n";
}
int main(int argc, char* argv[ ]) {
if(argc != 4) {
Usage( );
return 0;
}
cout << "jwSMTP library demo program\n\n";
string to(argv[1]);
string from(argv[2]);
string smtpserver(argv[3]);
char str[1024];
cout << "Please enter the subject of the mail\n";
cin.getline(str, 1024);
string subject(str);
strcpy(str, "");
cout << "Please enter the message body\n";
cin.getline(str, 1024);
string mailmessage(str);
// This is how to tell the mailer class that we are using a direct smtp server
// preventing the code from doing an MX lookup on 'smtpserver'
jwsmtp::mailer mail(to.c_str( ),
from.c_str( ),
subject.c_str( ),
mailmessage.c_str( ),
smtpserver.c_str( ),
jwsmtp::mailer::SMTP_PORT,
false);
// using a local file as opposed to a full path.
mail.attach("attach.png");
// boost::thread thrd(mail);
// thrd.join( ); // optional
// or:-
mail.operator ( )( );
cout << mail.response( ) << "\n";
return 0;
}