#include <iostream>
#include <jwsmtp/jwsmtp.h>
using std::cout;
using std::cin;
using std::string;
void Usage( ) {
cout << "jwSMTP library demo program\n"
"maildemo <email toaddress> <email fromaddress> <smtpserver>\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);
jwsmtp::mailer mail(to.c_str( ),
from.c_str( ),
subject.c_str( ),
mailmessage.c_str( ),
smtpserver.c_str( ),
jwsmtp::mailer::SMTP_PORT,
false);
mail.attach("attach.png");
mail.operator ( )( );
cout << mail.response( ) << "\n";
return 0;
}