--- parser3/src/classes/mail.C 2002/08/01 11:26:44 1.73 +++ parser3/src/classes/mail.C 2002/12/05 09:41:56 1.83 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_MAIL_C="$Id: mail.C,v 1.73 2002/08/01 11:26:44 paf Exp $"; +static const char* IDENT_MAIL_C="$Date: 2002/12/05 09:41:56 $"; #include "pa_config_includes.h" @@ -98,6 +98,7 @@ struct Mail_info { String *header; const String **from, **to; const String *errors_to; + bool mime_version_specified; }; #endif @@ -120,11 +121,13 @@ static void add_header_attribute(const H *mi.to=&extractEmail(element_value.as_string()); if(low_element_name=="errors-to") mi.errors_to=&extractEmail(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"; } @@ -198,6 +201,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)) { @@ -249,8 +254,8 @@ static const String& message_hash_to_str "\n"; // header|body separator const String& body=body_element->as_string(); - const void *body_ptr=body.cstr(); // body - size_t body_size=body.size(); // body + const char *body_ptr=body.cstr(String::UL_UNSPECIFIED); // body + size_t body_size=strlen(body_ptr); // body const void *mail_ptr; size_t mail_size; Charset::transcode(pool, @@ -271,15 +276,16 @@ static void sendmail(Request& r, const S const String *from, const String *to) { Pool& pool=r.pool(); - char *message_cstr=message.cstr(); + char *message_cstr=message.cstr(String::UL_UNSPECIFIED); Hash *mail_conf=static_cast(r.classes_conf.get(mail_base_class->name())); + const char *exception_type="email.format"; if(!from) - throw Exception("parser.runtime", + throw Exception(exception_type, &method_name, "parameter does not specify 'from' header field"); if(!to) - throw Exception("parser.runtime", + throw Exception(exception_type, &method_name, "parameter does not specify 'to' header field"); #ifdef _MSC_VER @@ -349,7 +355,7 @@ static void sendmail(Request& r, const S } if(!file_executable(*file_spec)) - throw Exception(0, + throw Exception("email.send", file_spec, "is not executable." #ifdef PA_FORCED_SENDMAIL @@ -374,7 +380,7 @@ static void sendmail(Request& r, const S &argv, in, out, err); if(exit_status || err.size()) - throw Exception(0, + throw Exception("email.send", &method_name, "'%s' reported problem: %s (%d)", file_spec->cstr(), @@ -399,7 +405,7 @@ static void _send(Request& r, const Stri const String *from, *to; 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 + static_cast(r.get_self())->message_hash_to_string(r, &method_name, hash, 0, &from, &to); // new //r.write_pass_lang(message); sendmail(r, method_name, message, from, to); @@ -418,7 +424,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)) + 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