--- parser3/src/classes/mail.C 2002/02/06 08:40:20 1.51 +++ parser3/src/classes/mail.C 2002/03/25 12:13:56 1.58 @@ -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.51 2002/02/06 08:40:20 paf Exp $ + $Id: mail.C,v 1.58 2002/03/25 12:13:56 paf Exp $ */ #include "pa_config_includes.h" @@ -368,43 +368,62 @@ static void sendmail(Request& r, const S // $MAIN:MAIL.sendmail["/usr/sbin/sendmail -t"] default // $MAIN:MAIL.sendmail["/usr/lib/sendmail -t"] default + const String *sendmail_command; +#ifdef PA_FORCED_SENDMAIL + sendmail_command=new(pool) String(pool, PA_FORCED_SENDMAIL); +#else const char *sendmailkey_cstr="sendmail"; - const String *sendmail_string; if(mail_conf) { if(Value *sendmail_value=static_cast(mail_conf->get(String(pool, sendmailkey_cstr)))) - sendmail_string=&sendmail_value->as_string(); + sendmail_command=&sendmail_value->as_string(); else throw Exception(0, 0, &method_name, "$"MAIN_CLASS_NAME":"MAIL_NAME".%s not defined", sendmailkey_cstr); } else { - sendmail_string=new(pool) String(pool, "/usr/sbin/sendmail"); - if(!file_executable(*sendmail_string)) - sendmail_string=new(pool) String(pool, "/usr/lib/sendmail"); - sendmail_string->APPEND_CONST("-t"); + 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"); + sendmail_command=test; } +#endif - // we know sendmail_string here + // we know sendmail_command here Array argv(pool); const String *file_spec; - int after_file_spec=sendmail_string->pos(" ", 1); + int after_file_spec=sendmail_command->pos(" ", 1); if(after_file_spec<=0) - file_spec=sendmail_string; + file_spec=sendmail_command; else { - size_t pos_after=after_file_spec+1; - file_spec=&sendmail_string->mid(0, pos_after); - sendmail_string->split(argv, &pos_after, " ", 1, String::UL_AS_IS); + size_t pos_after=after_file_spec; + file_spec=&sendmail_command->mid(0, pos_after++); + sendmail_command->split(argv, &pos_after, " ", 1, String::UL_AS_IS); } - if(!file_executable(*sendmail_string)) + if(!file_executable(*file_spec)) throw Exception(0, 0, - sendmail_string, - "is not executable. Set $"MAIN_CLASS_NAME":"MAIL_NAME".%s with appropriate sendmail command", - sendmailkey_cstr); + 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);