00001
00002
00003
00004
00005
00006
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
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
00047 ocSendMail( const char * sendMailPath );
00048 ~ocSendMail();
00049
00050 bool loadAddresses ( const char * path );
00051 const char * getAddress( const char * name );
00052
00053
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
00061 bool addHeader ( const char * header, const char * value );
00062
00063
00064 bool setMimeType( const char * type );
00065
00066
00067 bool write( const char * text );
00068
00069
00070 bool send( void );
00071
00072
00073 bool attach ( ocFile & inFile );
00074
00075
00076 bool urlAttach ( const char * url );
00077
00078
00079 inline string & body( void ) { return m_strBody; }
00080
00081 };
00082
00083 #endif
00084