00001 /* 00002 Class wrapper for postfix sendmail 00003 Postfix was written by: 00004 Wietse Venema of the IBM T.J. Watson Research (while on sabbatical.) 00005 Copyright ocSendMail 2002 - w3 systems development 00006 Author: David McCombs of - w3 systems development 00007 */ 00008 #ifndef OC_MAIL_H 00009 #define OC_MAIL_H 00010 00011 #include <cstdio> 00012 #include <string> 00013 #include <map> 00014 #include "ocCommon.h" 00015 00016 extern "C"{ 00017 #include <time.h> 00018 } 00019 00020 using namespace std; 00021 00022 typedef map< string, string> strStrMap; 00023 00024 /* 00025 class definition 00026 */ 00027 class ocSendMail 00028 { 00029 private: 00030 string m_strExePath; 00031 string m_strHeaders; 00032 string m_strBody; 00033 string m_beginBoundary; 00034 string m_endBoundary; 00035 FILE * m_pfOut; 00036 strStrMap m_addresses; 00037 string m_content_type; 00038 ocFiles m_files; 00039 tm tm_time; 00040 00041 void getTime( void ); 00042 string makeBoundary( void ); 00043 void decodeFile( ocFiles::iterator & pos ); 00044 public: 00045 00046 // constructor & destructor 00047 ocSendMail( const char * sendMailPath ); 00048 ~ocSendMail(); 00049 00050 bool loadAddresses ( const char * path ); 00051 const char * getAddress( const char * name ); 00052 00053 // open mail route to send mail to 00054 bool openRoute( const char * from, 00055 const char * to, 00056 const char * subject, 00057 const char * cc = NULL, 00058 const char * bcc = NULL ); 00059 00060 // add a custom header 00061 bool addHeader ( const char * header, const char * value ); 00062 00063 // set the mime type (text/plain by default) 00064 bool setMimeType( const char * type ); 00065 00066 // write a line into the message body 00067 bool write( const char * text ); 00068 00069 // send the whole mail message 00070 bool send( void ); 00071 00072 // add inline attachment 00073 bool attach ( ocFile & inFile ); 00074 00075 // add an attachment as a public url 00076 bool urlAttach ( const char * url ); 00077 00078 // return the body 00079 inline string & body( void ) { return m_strBody; } 00080 00081 }; 00082 00083 #endif 00084
1.5.5