|
|
| version 1.51, 2002/02/06 08:40:20 | version 1.58, 2002/03/25 12:13:56 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b mail parser class. | Parser: @b mail parser class. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| $Id$ | $Id$ |
| */ | */ |
| Line 368 static void sendmail(Request& r, const S | Line 368 static void sendmail(Request& r, const S |
| // $MAIN:MAIL.sendmail["/usr/sbin/sendmail -t"] default | // $MAIN:MAIL.sendmail["/usr/sbin/sendmail -t"] default |
| // $MAIN:MAIL.sendmail["/usr/lib/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 char *sendmailkey_cstr="sendmail"; |
| const String *sendmail_string; | |
| if(mail_conf) { | if(mail_conf) { |
| if(Value *sendmail_value=static_cast<Value *>(mail_conf->get(String(pool, sendmailkey_cstr)))) | if(Value *sendmail_value=static_cast<Value *>(mail_conf->get(String(pool, sendmailkey_cstr)))) |
| sendmail_string=&sendmail_value->as_string(); | sendmail_command=&sendmail_value->as_string(); |
| else | else |
| throw Exception(0, 0, | throw Exception(0, 0, |
| &method_name, | &method_name, |
| "$"MAIN_CLASS_NAME":"MAIL_NAME".%s not defined", | "$"MAIN_CLASS_NAME":"MAIL_NAME".%s not defined", |
| sendmailkey_cstr); | sendmailkey_cstr); |
| } else { | } else { |
| sendmail_string=new(pool) String(pool, "/usr/sbin/sendmail"); | String *test=new(pool) String(pool, "/usr/sbin/sendmail"); |
| if(!file_executable(*sendmail_string)) | if(!file_executable(*test)) |
| sendmail_string=new(pool) String(pool, "/usr/lib/sendmail"); | test=new(pool) String(pool, "/usr/lib/sendmail"); |
| sendmail_string->APPEND_CONST("-t"); | test->APPEND_CONST(" -t"); |
| sendmail_command=test; | |
| } | } |
| #endif | |
| // we know sendmail_string here | // we know sendmail_command here |
| Array argv(pool); | Array argv(pool); |
| const String *file_spec; | 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) | if(after_file_spec<=0) |
| file_spec=sendmail_string; | file_spec=sendmail_command; |
| else { | else { |
| size_t pos_after=after_file_spec+1; | size_t pos_after=after_file_spec; |
| file_spec=&sendmail_string->mid(0, pos_after); | file_spec=&sendmail_command->mid(0, pos_after++); |
| sendmail_string->split(argv, &pos_after, " ", 1, String::UL_AS_IS); | 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, | throw Exception(0, 0, |
| sendmail_string, | file_spec, |
| "is not executable. Set $"MAIN_CLASS_NAME":"MAIL_NAME".%s with appropriate sendmail command", | "is not executable." |
| sendmailkey_cstr); | #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); | 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*/, | 0/*default env*/, |
| &argv, | &argv, |
| in, out, err); | in, out, err); |