--- parser3/src/classes/mail.C 2002/12/05 15:00:00 1.84 +++ parser3/src/classes/mail.C 2003/02/03 11:40:56 1.88.2.2 @@ -1,11 +1,11 @@ /** @file Parser: @b mail parser class. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_MAIL_C="$Date: 2002/12/05 15:00:00 $"; +static const char* IDENT_MAIL_C="$Date: 2003/02/03 11:40:56 $"; #include "pa_config_includes.h" @@ -33,7 +33,7 @@ const int ATTACHMENT_WEIGHT=100; // global variable -Methoded *mail_base_class; +MethodedPtr mail_base_class; // class @@ -70,7 +70,7 @@ static const String& attach_hash_to_stri file_name=&vfile_name->as_string(); else // no $file-name, VFile surely knows name file_name=&static_cast(vfile->fields().get(*name_name))->as_string(); - const char *file_name_cstr=file_name->cstr(); + const char* file_name_cstr=file_name->cstr(); String& result=*new(pool) String(pool); @@ -94,7 +94,7 @@ static const String& attach_hash_to_stri #ifndef DOXYGEN struct Mail_info { - Charset *charset; const char *content_charset_name; + Charset *charset; const char* content_charset_name; String *header; const String **from; String **to; @@ -141,7 +141,7 @@ struct Mail_seq_item { }; #endif static int get_part_name_weight(const Hash::Key& part_name) { - const char *cstr=part_name.cstr(); + const char* cstr=part_name.cstr(); int offset=0; if(strncmp(cstr, "text", 4)==0) { cstr+=4; @@ -184,7 +184,7 @@ static const String& message_hash_to_str else charset=&pool.get_source_charset(); - const char *content_charset_name=0; + const char* content_charset_name=0; if(Value *vcontent_type=static_cast(message_hash.get(*content_type_name))) if(Hash *hcontent_type=vcontent_type->get_hash(0)) if(Value *vcontentcharset_name=static_cast(hcontent_type->get(*charset_name))) @@ -255,7 +255,7 @@ static const String& message_hash_to_str "\n"; // header|body separator const String& body=body_element->as_string(); - const char *body_ptr=body.cstr(String::UL_UNSPECIFIED); // body + const char* body_ptr=body.cstr(String::UL_UNSPECIFIED); // body size_t body_size=strlen(body_ptr); // body const void *mail_ptr; size_t mail_size; @@ -280,16 +280,17 @@ static void sendmail(Request& r, const S char *message_cstr=message.cstr(String::UL_UNSPECIFIED); Hash *mail_conf=static_cast(r.classes_conf.get(mail_base_class->name())); - const char *exception_type="email.format"; - if(!from) + const char* exception_type="email.format"; + if(!from) // we use in sendmail -f {from} && SMTP MAIL from: {from} throw Exception(exception_type, &method_name, "parameter does not specify 'from' header field"); - if(!to) + +#ifdef _MSC_VER + if(!to) // we use only in SMTP RCPT to: {to} throw Exception(exception_type, &method_name, "parameter does not specify 'to' header field"); -#ifdef _MSC_VER SMTP& smtp=*new(pool) SMTP(pool, method_name); Value *server_port; @@ -298,7 +299,7 @@ static void sendmail(Request& r, const S (server_port=static_cast(mail_conf->get( *new(pool) String(pool, "SMTP"))))) { char *server=server_port->as_string().cstr(); - const char *port=rsplit(server, ':'); + const char* port=rsplit(server, ':'); if(!port) port="25"; @@ -313,11 +314,14 @@ static void sendmail(Request& r, const S // $MAIN:MAIL.sendmail["/usr/lib/sendmail -t -i -f postmaster"] default const String *sendmail_command; + const char* sendmailkey_cstr="sendmail"; + if(mail_conf) { #ifdef PA_FORCED_SENDMAIL - sendmail_command=new(pool) String(pool, PA_FORCED_SENDMAIL); + throw Exception("parser.runtime", + &method_name, + "Parser was configured with --with-sendmail="PA_FORCED_SENDMAIL + " key, to change sendmail you should reconfigure and recompie it"); #else - const char *sendmailkey_cstr="sendmail"; - if(mail_conf) { if(Value *sendmail_value=static_cast(mail_conf->get(String(pool, sendmailkey_cstr)))) sendmail_command=&sendmail_value->as_string(); else @@ -325,14 +329,18 @@ static void sendmail(Request& r, const S &method_name, "$"MAIN_CLASS_NAME":"MAIL_NAME".%s not defined", sendmailkey_cstr); +#endif } else { +#ifdef PA_FORCED_SENDMAIL + sendmail_command=new(pool) String(pool, PA_FORCED_SENDMAIL); +#else String *test=new(pool) String(pool, "/usr/sbin/sendmail"); if(!file_executable(*test)) test=new(pool) String(pool, "/usr/lib/sendmail"); test->APPEND_CONST(" -t -i -f postmaster"); sendmail_command=test; - } #endif + } // we know sendmail_command here, should replace "postmaster" with "$from" from message int at_postmaster=sendmail_command->pos("postmaster"); @@ -403,10 +411,10 @@ static void _send(Request& r, const Stri &method_name, "message must be hash"); - const String *from; - String *to; + const String *from=0; + String *to=0; String **to_param= -#ifdef WIN32 +#ifdef _MSC_VER &to #else 0