#include #include #include #include #include #include #include #include #include #include "safestring.h" #include #include #include #include #include #include //#include "general_types.h" #include "clog.h" //#include "mx.h" #include "smtp.h" #include "timer.h" //#include "socket.h" int SMTP2( const char * _server, const char * _from, char * _to, char * _body, const char * _domain, const char * _user, const char * _pass, const char * _name) { // SAF 1/24/03: first copy all data to local structures to avoid race conditions, which is currently causing crashes ! // Actually, it wasn't the race condition, it was the fact that '_to' was NULL due to a bug in profile.cpp: "email" was not set logfmt( FLOG_MAX, "ESMTP( %s, %s, %s )", _server, _from, _to ); if ( !_server || !_from || !_to || !_body ) { logfmt( FLOG_MAX, "Input parameters server, from, to & body are requied" ); return 0; } if ( !_to[0]) { logfmt( FLOG_MAX, "Empty recipient list" ); return 0; } int BUF_SIZE = 512+strlen(_server)+strlen(_from)+strlen(_to)+strlen(_domain)+strlen(_user)+strlen(_pass)+strlen(_name)+2*strlen(_body); char *subject = NULL, *body = NULL; char *name = new char[BUF_SIZE+1]; // Prepare body & subject logfmt( FLOG_MAX, "Prepare body" ); int lines = 0; int len = strlen( _body ); for ( int i=0; i 9) { subject = new char[i+1]; memset( subject, 0, i ); int j = 9; for (; j 0) { logfmt( FLOG_MAX, "%s", name ); } else { logfmt( FLOG_MAX, "\n\nEND OF PIPE OUTPUT\n\n" ); } } while (c > 0); pclose( p ); if (name != NULL) { delete name; } if (subject != NULL) { delete subject; } if (body != NULL) { delete body; } logfmt( FLOG_MAX, "/ESMTP()" ); return 1; }