|
|
| version 1.136, 2023/09/26 20:49:06 | version 1.139, 2026/04/25 13:38:46 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b mail parser class. | Parser: @b mail parser class. |
| Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) |
| Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| Line 35 const int ATTACHMENT_WEIGHT=100; | Line 35 const int ATTACHMENT_WEIGHT=100; |
| class MMail: public Methoded { | class MMail: public Methoded { |
| public: // Methoded | public: // Methoded |
| bool used_directly() { return false; } | bool used_directly() { return false; } |
| void configure_user(Request& r); | |
| public: | public: |
| MMail(); | MMail(); |
| Line 190 static void _send(Request& r, MethodPara | Line 189 static void _send(Request& r, MethodPara |
| if(Value* vdebug=hash->get(MAIL_DEBUG_NAME)) | if(Value* vdebug=hash->get(MAIL_DEBUG_NAME)) |
| print_debug=vdebug->as_bool(); | print_debug=vdebug->as_bool(); |
| Value* vmail_conf=static_cast<Value*>(r.classes_conf.get(mail_class->type())); | Value* vmail_conf=r.main_class.get_element(mail_name); |
| Value* smtp_server_port=0; | Value* smtp_server_port=0; |
| if(vmail_conf) { | if(vmail_conf) { |
| // $MAIN:MAIL.SMTP[mail.yourdomain.ru[:port]] | if(vmail_conf->get_hash()) { |
| smtp_server_port=vmail_conf->get_hash()->get("SMTP"); | // $MAIN:MAIL.SMTP[mail.yourdomain.ru[:port]] |
| smtp_server_port=vmail_conf->get_hash()->get("SMTP"); | |
| } else { | |
| if( !vmail_conf->is_string() ) | |
| throw Exception(PARSER_RUNTIME, 0, "$" MAIL_CLASS_NAME ":" MAIL_NAME " is not hash"); | |
| vmail_conf=0; | |
| } | |
| } | } |
| const String* from=0; | const String* from=0; |
| Line 213 MMail::MMail(): Methoded(MAIL_CLASS_NAME | Line 219 MMail::MMail(): Methoded(MAIL_CLASS_NAME |
| // ^mail:send{hash} | // ^mail:send{hash} |
| add_native_method("send", Method::CT_STATIC, _send, 1, 1); | add_native_method("send", Method::CT_STATIC, _send, 1, 1); |
| } | } |
| void MMail::configure_user(Request& r) { | |
| // $MAIN:MAIL[$SMTP[mail.design.ru]] | |
| if(Value* mail_element=r.main_class.get_element(mail_name)) { | |
| if(mail_element->get_hash()) | |
| r.classes_conf.put(type(), mail_element); | |
| else | |
| if( !mail_element->is_string() ) | |
| throw Exception(PARSER_RUNTIME, 0, "$" MAIL_CLASS_NAME ":" MAIL_NAME " is not hash"); | |
| } | |
| } |