--- parser3/src/classes/mail.C 2002/02/06 08:54:22 1.52 +++ parser3/src/classes/mail.C 2002/03/27 15:30:34 1.60 @@ -1,10 +1,10 @@ /** @file Parser: @b mail parser class. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://paf.design.ru) + Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) - $Id: mail.C,v 1.52 2002/02/06 08:54:22 paf Exp $ + $Id: mail.C,v 1.60 2002/03/27 15:30:34 paf Exp $ */ #include "pa_config_includes.h" @@ -137,7 +137,7 @@ static const String& attach_hash_to_stri if(Value *value=static_cast(attach_hash.get(*value_name))) vfile=value->as_vfile(String::UL_AS_IS); // bad with html attaches. todo: solve else - throw Exception(0, 0, + throw Exception("parser.runtime", &origin_string, "has no $value"); @@ -160,7 +160,7 @@ static const String& attach_hash_to_stri if(!type/*default = uue*/ || *type=="uue") { uuencode(result, file_name_cstr, *vfile); } else // for now - throw Exception(0, 0, + throw Exception("parser.runtime", type, "unknown attachment encode format"); @@ -216,7 +216,7 @@ static int get_part_name_weight(const Ha cstr+=6; offset=ATTACHMENT_WEIGHT; } else - throw Exception(0, 0, + throw Exception("parser.runtime", &part_name, "is neither text# nor attach#"); @@ -298,7 +298,7 @@ static const String& letter_hash_to_stri result << letter_hash_to_string(r, method_name, *part_hash, level+1, 0, 0); else - throw Exception(0, 0, + throw Exception("parser.runtime", seq[i].name, "part is not hash"); } @@ -322,7 +322,7 @@ static const String& letter_hash_to_stri result.APPEND_CLEAN((const char*)mail_ptr, mail_size, 0, 0); } } else - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "has no $body"); @@ -339,11 +339,11 @@ static void sendmail(Request& r, const S #ifdef _MSC_VER if(!from) - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "has no 'from' header specified"); if(!to) - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "has no 'to' header specified"); @@ -360,7 +360,7 @@ static void sendmail(Request& r, const S smtp.Send(server, port, letter_cstr, from->cstr(), to->cstr()); } else - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "$"MAIN_CLASS_NAME":"MAIL_NAME".SMTP not defined"); #else @@ -368,13 +368,16 @@ static void sendmail(Request& r, const S // $MAIN:MAIL.sendmail["/usr/sbin/sendmail -t"] default // $MAIN:MAIL.sendmail["/usr/lib/sendmail -t"] default - const char *sendmailkey_cstr="sendmail"; const String *sendmail_command; +#ifdef PA_FORCED_SENDMAIL + sendmail_command=new(pool) String(pool, PA_FORCED_SENDMAIL); +#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 - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "$"MAIN_CLASS_NAME":"MAIL_NAME".%s not defined", sendmailkey_cstr); @@ -385,6 +388,7 @@ static void sendmail(Request& r, const S test->APPEND_CONST(" -t"); sendmail_command=test; } +#endif // we know sendmail_command here Array argv(pool); @@ -399,18 +403,32 @@ static void sendmail(Request& r, const S } if(!file_executable(*file_spec)) - throw Exception(0, 0, - file_spec, - "is not executable. Set $"MAIN_CLASS_NAME":"MAIL_NAME".%s with appropriate sendmail command", - sendmailkey_cstr); + throw Exception(0, + file_spec, + "is not executable." +#ifdef PA_FORCED_SENDMAIL + " Use configure key \"--with-sendmail=appropriate sendmail command\"" +#else + " Set $"MAIN_CLASS_NAME":"MAIL_NAME".%s with appropriate sendmail command", + sendmailkey_cstr +#endif + ); + String in(pool, letter_cstr); String out(pool); String err(pool); - int exit_status=pa_exec(*file_spec, + int exit_status=pa_exec( + // forced_allow +#ifdef PA_FORCED_SENDMAIL + true +#else + false +#endif + , *file_spec, 0/*default env*/, &argv, in, out, err); if(exit_status || err.size()) - throw Exception(0, 0, + throw Exception(0, &method_name, "'%s' reported problem: %s (%d)", file_spec->cstr(), @@ -428,7 +446,7 @@ static void _send(Request& r, const Stri Value& vhash=params->as_no_junction(0, "message must not be code"); Hash *hash=vhash.get_hash(&method_name); if(!hash) - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "message must be hash"); @@ -460,7 +478,7 @@ void MMail::configure_user(Request& r) { if(Hash *mail_conf=mail_element->get_hash(0)) r.classes_conf.put(name(), mail_conf); else - throw Exception(0, 0, + throw Exception("parser.runtime", 0, "$" MAIL_CLASS_NAME ":" MAIL_NAME " is not hash"); }