|
|
| version 1.131, 2016/11/01 23:10:40 | version 1.135, 2020/12/15 17:10:29 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b mail parser class. | Parser: @b mail parser class. |
| Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 72 static void sendmail( | Line 72 static void sendmail( |
| ) { | ) { |
| const char* exception_type="email.format"; | const char* exception_type="email.format"; |
| if(!from) // we use in sendmail -f {from} && SMTP MAIL from: {from} | if(!from) // we use in sendmail -f {from} && SMTP MAIL from: {from} |
| throw Exception(exception_type, | throw Exception(exception_type, 0, "parameter does not specify 'from' header field"); |
| 0, | |
| "parameter does not specify 'from' header field"); | |
| const char* message_cstr=message.untaint_cstr(String::L_AS_IS); | const char* message_cstr=message.untaint_cstr(String::L_AS_IS); |
| if(smtp_server_port) { | if(smtp_server_port) { |
| if(!to) // we use only in SMTP RCPT to: {to} | if(!to) // we use only in SMTP RCPT to: {to} |
| throw Exception(exception_type, | throw Exception(exception_type, 0, "parameter does not specify 'to' header field"); |
| 0, | |
| "parameter does not specify 'to' header field"); | |
| SMTP smtp; | SMTP smtp; |
| char* server=smtp_server_port->as_string().cstrm(); | char* server=smtp_server_port->as_string().cstrm(); |
| Line 96 static void sendmail( | Line 92 static void sendmail( |
| #ifdef WIN32 | #ifdef WIN32 |
| // win32 without SMTP server configured | // win32 without SMTP server configured |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, 0, "$" MAIN_CLASS_NAME ":" MAIL_NAME ".SMTP not defined"); |
| 0, | |
| "$" MAIN_CLASS_NAME ":" MAIL_NAME ".SMTP not defined"); | |
| #else | #else |
| // unix | // unix |
| // $MAIN:MAIL.sendmail["/usr/sbin/sendmail -t -i -f postmaster"] default | // $MAIN:MAIL.sendmail["/usr/sbin/sendmail -t -i -f postmaster"] default |
| Line 115 static void sendmail( | Line 109 static void sendmail( |
| if(Value* sendmail_value=vmail_conf->get_hash()->get(mail_sendmail_name)) | if(Value* sendmail_value=vmail_conf->get_hash()->get(mail_sendmail_name)) |
| *sendmail_command<<sendmail_value->as_string(); | *sendmail_command<<sendmail_value->as_string(); |
| else | else |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, 0, "$" MAIN_CLASS_NAME ":" MAIL_NAME "." SENDMAIL_NAME " not defined"); |
| 0, | |
| "$" MAIN_CLASS_NAME ":" MAIL_NAME "." SENDMAIL_NAME " not defined"); | |
| #endif | #endif |
| } else { | } else { |
| #ifdef PA_FORCED_SENDMAIL | #ifdef PA_FORCED_SENDMAIL |
| Line 164 static void sendmail( | Line 156 static void sendmail( |
| #endif | #endif |
| ); | ); |
| String in(message_cstr); | |
| PA_exec_result exec=pa_exec( | PA_exec_result exec=pa_exec( |
| // forced_allow | // forced_allow |
| #ifdef PA_FORCED_SENDMAIL | #ifdef PA_FORCED_SENDMAIL |
| Line 176 static void sendmail( | Line 166 static void sendmail( |
| , *file_spec, | , *file_spec, |
| 0 /* pass env */, | 0 /* pass env */, |
| argv, | argv, |
| in); | String::C(message_cstr, strlen(message_cstr))); |
| if(exec.status || exec.err.length()) | if(exec.status || exec.err.length()) |
| throw Exception("email.send", | throw Exception("email.send", 0, "'%s' reported problem: %s (%d)", file_spec->cstr(), exec.err.length() ? exec.err.cstr() : "UNKNOWN", exec.status); |
| 0, | |
| "'%s' reported problem: %s (%d)", | |
| file_spec->cstr(), | |
| exec.err.length()?exec.err.cstr():"UNKNOWN", | |
| exec.status); | |
| #endif //WIN32 | #endif //WIN32 |
| } | } |
| Line 211 static void _send(Request& r, MethodPara | Line 197 static void _send(Request& r, MethodPara |
| smtp_server_port=vmail_conf->get_hash()->get("SMTP"); | smtp_server_port=vmail_conf->get_hash()->get("SMTP"); |
| } | } |
| const String* from=0; | const String* from=0; |
| String* to=0; | String* to=0; |
| const String& message= | const String& message = GET_SELF(r, VMail).message_hash_to_string(r, hash, from, smtp_server_port ? true : false /*send by SMTP=strip to?*/, to); |
| GET_SELF(r, VMail).message_hash_to_string(r, hash, 0, from, | |
| smtp_server_port?true:false /*send by SMTP=strip to?*/, to); | |
| if(print_debug) | if(print_debug) |
| r.write(message); | r.write(message); |
| Line 239 void MMail::configure_user(Request& r) { | Line 222 void MMail::configure_user(Request& r) { |
| r.classes_conf.put(type(), mail_element); | r.classes_conf.put(type(), mail_element); |
| else | else |
| if( !mail_element->is_string() ) | if( !mail_element->is_string() ) |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, 0, "$" MAIL_CLASS_NAME ":" MAIL_NAME " is not hash"); |
| 0, | |
| "$" MAIL_CLASS_NAME ":" MAIL_NAME " is not hash"); | |
| } | } |
| } | } |