--- parser3/src/classes/mail.C 2002/12/05 09:41:56 1.83 +++ parser3/src/classes/mail.C 2002/12/24 08:41:55 1.86 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_MAIL_C="$Date: 2002/12/05 09:41:56 $"; +static const char* IDENT_MAIL_C="$Date: 2002/12/24 08:41:55 $"; #include "pa_config_includes.h" @@ -96,13 +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); @@ -116,11 +117,11 @@ 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; @@ -171,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" @@ -280,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; @@ -312,11 +314,14 @@ static void sendmail(Request& r, const S // $MAIN:MAIL.sendmail["/usr/lib/sendmail -t -i -f postmaster"] default const String *sendmail_command; -#ifdef PA_FORCED_SENDMAIL - sendmail_command=new(pool) String(pool, PA_FORCED_SENDMAIL); -#else const char *sendmailkey_cstr="sendmail"; if(mail_conf) { +#ifdef PA_FORCED_SENDMAIL + throw Exception("parser.runtime", + &method_name, + "Parser was configured with --with-sendmail="PA_FORCED_SENDMAIL + " key, to change sendmail you should reconfigure and recompie it").; +#else if(Value *sendmail_value=static_cast(mail_conf->get(String(pool, sendmailkey_cstr)))) sendmail_command=&sendmail_value->as_string(); else @@ -324,14 +329,18 @@ static void sendmail(Request& r, const S &method_name, "$"MAIN_CLASS_NAME":"MAIL_NAME".%s not defined", sendmailkey_cstr); +#endif } else { +#ifdef PA_FORCED_SENDMAIL + sendmail_command=new(pool) String(pool, PA_FORCED_SENDMAIL); +#else String *test=new(pool) String(pool, "/usr/sbin/sendmail"); if(!file_executable(*test)) test=new(pool) String(pool, "/usr/lib/sendmail"); test->APPEND_CONST(" -t -i -f postmaster"); sendmail_command=test; - } #endif + } // we know sendmail_command here, should replace "postmaster" with "$from" from message int at_postmaster=sendmail_command->pos("postmaster"); @@ -402,10 +411,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.get_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);