00001 #include<string>
00002 #include<iostream>
00003 #include<fstream>
00004 #include<iomanip>
00005 #include"oc_Mail.h"
00006
00007 static char * exePath = "/usr/sbin/sendmail";
00008
00009 int main( int argc, char ** argv )
00010 {
00011 ocSendMail sendMail("127.0.0.1");
00012 sendMail.setMimeType("text/html");
00013 sendMail.loadAddresses( "./addresses" );
00014 string loco = sendMail.getAddress("local");
00015 string foreign = sendMail.getAddress("foreign");
00016 cout << "local is " << loco << endl;
00017 cout << "foreign is : " << foreign << endl;
00018
00019 if( ! sendMail.openRoute( loco, foreign, "Mail Test - W3 Systems Design" ) )
00020 {
00021 cout << "open route Failure!!!" << sendMail.sendResult() << endl;
00022 return 1;
00023 }
00024
00025
00026 ifstream body( "mailBody.txt" );
00027 string & mbody = sendMail.body();
00028 char c;
00029 while ( body.get(c) )
00030 {
00031 mbody += c;
00032 }
00033 if(!sendMail.send())
00034 cout << "send Failure!!!" << sendMail.sendResult() << endl;
00035
00036 return 0;
00037 }
00038