--- parser3/src/classes/mail.C 2002/08/13 15:55:41 1.78 +++ parser3/src/classes/mail.C 2002/12/19 08:34:32 1.85 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_MAIL_C="$Date: 2002/08/13 15:55:41 $"; +static const char* IDENT_MAIL_C="$Date: 2002/12/19 08:34:32 $"; #include "pa_config_includes.h" @@ -96,12 +96,14 @@ static const String& attach_hash_to_stri struct Mail_info { Charset *charset; const char *content_charset_name; String *header; - const String **from, **to; + const String **from; + String **to; const String *errors_to; + bool mime_version_specified; }; #endif -const String& extractEmail(const String& string); +String& extractEmails(const String& string); static void add_header_attribute(const Hash::Key& raw_element_name, Hash::Val *aelement_value, void *info) { Value& element_value=*static_cast(aelement_value); @@ -115,16 +117,18 @@ static void add_header_attribute(const H // fetch from & to from header for SMTP if(mi.from && low_element_name=="from") - *mi.from=&extractEmail(element_value.as_string()); + *mi.from=&extractEmails(element_value.as_string()); if(mi.to && low_element_name=="to") - *mi.to=&extractEmail(element_value.as_string()); + *mi.to=&extractEmails(element_value.as_string()); if(low_element_name=="errors-to") - mi.errors_to=&extractEmail(element_value.as_string()); + mi.errors_to=&extractEmails(element_value.as_string()); + if(low_element_name=="mime-version") + mi.mime_version_specified=true; // append header line *mi.header << low_element_name << ":" << - attributed_meaning_to_string(element_value, String::UL_MAIL_HEADER). + attributed_meaning_to_string(element_value, String::UL_MAIL_HEADER, true). cstr(String::UL_UNSPECIFIED, 0, mi.charset, mi.content_charset_name) << "\n"; } @@ -168,7 +172,7 @@ static int sort_cmp_string_double_value( } static const String& message_hash_to_string(Request& r, const String& method_name, Hash& message_hash, int level, - const String **from, const String **to) { + const String **from, String **to) { Pool& pool=r.pool(); // prepare header: 'hash' without "body" @@ -198,6 +202,8 @@ static const String& message_hash_to_str message_hash.for_each(add_header_attribute, &mail_info); if(!mail_info.errors_to) result << "errors-to: postmaster\n"; // errors-to: default + if(!mail_info.mime_version_specified) + result << "MIME-Version: 1.0\n"; // MIME-Version: default if(Value *body_element=static_cast(message_hash.get(*body_name))) { if(Hash *body_hash=body_element->get_hash(&method_name)) { @@ -275,15 +281,16 @@ static void sendmail(Request& r, const S Hash *mail_conf=static_cast(r.classes_conf.get(mail_base_class->name())); const char *exception_type="email.format"; - if(!from) + if(!from) // we use in sendmail -f {from} && SMTP MAIL from: {from} throw Exception(exception_type, &method_name, "parameter does not specify 'from' header field"); - if(!to) + +#ifdef _MSC_VER + if(!to) // we use only in SMTP RCPT to: {to} throw Exception(exception_type, &method_name, "parameter does not specify 'to' header field"); -#ifdef _MSC_VER SMTP& smtp=*new(pool) SMTP(pool, method_name); Value *server_port; @@ -397,10 +404,18 @@ static void _send(Request& r, const Stri &method_name, "message must be hash"); - const String *from, *to; + const String *from=0; + String *to=0; + String **to_param= +#ifdef _MSC_VER + &to +#else + 0 +#endif + ; const String& message=hash->get(*body_name)/*old format*/? - message_hash_to_string(r, method_name, *hash, 0, &from, &to) : // old - static_cast(r.self)->message_hash_to_string(r, &method_name, hash, 0, &from, &to); // new + message_hash_to_string(r, method_name, *hash, 0, &from, to_param) : // old + static_cast(r.get_self())->message_hash_to_string(r, &method_name, hash, 0, &from, to_param); // new //r.write_pass_lang(message); sendmail(r, method_name, message, from, to); @@ -419,7 +434,7 @@ void MMail::configure_user(Request& r) { Pool& pool=r.pool(); // $MAIN:MAIL[$SMTP[mail.design.ru]] - if(Value *mail_element=r.main_class->get_element(mail_name, r.main_class, false)) + if(Value *mail_element=r.main_class.get_element(mail_name, r.main_class, false)) if(Hash *mail_conf=mail_element->get_hash(0)) r.classes_conf.put(name(), mail_conf); else