|
|
| version 1.88.2.16.2.16, 2003/04/01 13:53:26 | version 1.91, 2003/11/04 12:29:16 |
|---|---|
| Line 26 static const char* IDENT_MAIL_C="$Date$" | Line 26 static const char* IDENT_MAIL_C="$Date$" |
| // defines | // defines |
| #define MAIL_CLASS_NAME "mail" | #define MAIL_CLASS_NAME "mail" |
| #define MAIL_SENDMAIL_NAME "sendmail" | #define SENDMAIL_NAME "sendmail" |
| // consts | // consts |
| Line 54 DECLARE_CLASS_VAR(mail, 0/*fictive*/, ne | Line 54 DECLARE_CLASS_VAR(mail, 0/*fictive*/, ne |
| // statics | // statics |
| static const String mail_name(MAIL_NAME); | static const String mail_name(MAIL_NAME); |
| static const String mail_sendmail_name(MAIL_SENDMAIL_NAME); | static const String mail_sendmail_name(SENDMAIL_NAME); |
| // helpers | // helpers |
| static void sendmail(Request& r, | static void sendmail(Request& r, |
| const String& message, | const String& message, |
| const String* from, const String* to) { | const String* from, const String* to, |
| const String* options) { | |
| const char* message_cstr=message.cstr(String::L_UNSPECIFIED); | const char* message_cstr=message.cstr(String::L_UNSPECIFIED); |
| Value* vmail_conf=static_cast<Value*>(r.classes_conf.get(mail_base_class->name())); | Value* vmail_conf=static_cast<Value*>(r.classes_conf.get(mail_base_class->name())); |
| Line 80 static void sendmail(Request& r, | Line 81 static void sendmail(Request& r, |
| Value* server_port; | Value* server_port; |
| // $MAIN:MAIL.SMTP[mail.yourdomain.ru[:port]] | // $MAIN:MAIL.SMTP[mail.yourdomain.ru[:port]] |
| if(vmail_conf && | if(vmail_conf && |
| (server_port=vmail_conf->get_hash()->get(StringBody("SMTP")))) { | (server_port=vmail_conf->get_hash()->get(String::Body("SMTP")))) { |
| char* server=server_port->as_string().cstrm(); | char* server=server_port->as_string().cstrm(); |
| const char* port=rsplit(server, ':'); | const char* port=rsplit(server, ':'); |
| if(!port) | if(!port) |
| Line 109 static void sendmail(Request& r, | Line 110 static void sendmail(Request& r, |
| else | else |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |
| 0, | 0, |
| "$"MAIN_CLASS_NAME":"MAIL_NAME"."MAIL_SENDMAIL_NAME" not defined"); | "$"MAIN_CLASS_NAME":"MAIL_NAME"."SENDMAIL_NAME" not defined"); |
| #endif | #endif |
| } else { | } else { |
| #ifdef PA_FORCED_SENDMAIL | #ifdef PA_FORCED_SENDMAIL |
| Line 122 static void sendmail(Request& r, | Line 123 static void sendmail(Request& r, |
| sendmail_command=test; | sendmail_command=test; |
| #endif | #endif |
| } | } |
| if(options) | |
| sendmail_command<<" "<<*options; | |
| // we know sendmail_command here, should replace "postmaster" with "$from" from message | // we know sendmail_command here, should replace "postmaster" with "$from" from message |
| size_t at_postmaster=sendmail_command->pos("postmaster"); | size_t at_postmaster=sendmail_command->pos("postmaster"); |
| Line 151 static void sendmail(Request& r, | Line 154 static void sendmail(Request& r, |
| #ifdef PA_FORCED_SENDMAIL | #ifdef PA_FORCED_SENDMAIL |
| " Use configure key \"--with-sendmail=appropriate sendmail command\"" | " Use configure key \"--with-sendmail=appropriate sendmail command\"" |
| #else | #else |
| " Set $"MAIN_CLASS_NAME":"MAIL_NAME"."MAIL_SENDMAIL_NAME" to appropriate sendmail command" | " Set $"MAIN_CLASS_NAME":"MAIL_NAME"."SENDMAIL_NAME" to appropriate sendmail command" |
| #endif | #endif |
| ); | ); |
| Line 180 static void sendmail(Request& r, | Line 183 static void sendmail(Request& r, |
| // methods | // methods |
| static void _send(Request& r, MethodParams* params) { | static void _send(Request& r, MethodParams& params) { |
| Value& vhash=params->as_no_junction(0, "message must not be code"); | Value& vhash=params.as_no_junction(0, "message must not be code"); |
| HashStringValue* hash=vhash.get_hash(); | HashStringValue* hash=vhash.get_hash(); |
| if(!hash) | if(!hash) |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |
| 0, | 0, |
| "message must be hash"); | "message must be hash"); |
| const String* soptions=0; | |
| if(Value* voptions=hash->get(MAIL_OPTIONS_NAME)) | |
| soptions=&voptions->as_string(); | |
| const String* from=0; | const String* from=0; |
| String* to=0; | String* to=0; |
| const String& message= | const String& message= |
| Line 200 static void _send(Request& r, MethodPara | Line 207 static void _send(Request& r, MethodPara |
| , to); | , to); |
| //r.write_pass_lang(message); | //r.write_pass_lang(message); |
| sendmail(r, message, from, to); | sendmail(r, message, from, to, soptions); |
| } | } |
| // constructor & configurator | // constructor & configurator |