--- parser3/src/classes/mail.C 2003/11/21 12:38:20 1.96 +++ parser3/src/classes/mail.C 2004/02/24 11:26:29 1.103 @@ -1,11 +1,11 @@ /** @file Parser: @b mail parser class. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_MAIL_C="$Date: 2003/11/21 12:38:20 $"; +static const char * const IDENT_MAIL_C="$Date: 2004/02/24 11:26:29 $"; #include "pa_config_includes.h" #include "pa_vmethod_frame.h" @@ -19,9 +19,7 @@ static const char * const IDENT_MAIL_C=" #include "pa_uue.h" #include "pa_vmail.h" -#ifdef _MSC_VER -# include "smtp/smtp.h" -#endif +#include "smtp.h" // defines @@ -60,11 +58,7 @@ static const String mail_sendmail_name(S static void sendmail(Request& r, const String& message, - const String* from, const String* -#ifdef _MSC_VER - to -#endif - , + const String* from, const String* to, const String* #ifndef _MSC_VER options @@ -78,28 +72,32 @@ static void sendmail(Request& r, throw Exception(exception_type, 0, "parameter does not specify 'from' header field"); - -#ifdef _MSC_VER if(!to) // we use only in SMTP RCPT to: {to} throw Exception(exception_type, 0, "parameter does not specify 'to' header field"); - SMTP smtp; - Value* server_port; - // $MAIN:MAIL.SMTP[mail.yourdomain.ru[:port]] - if(vmail_conf && - (server_port=vmail_conf->get_hash()->get(String::Body("SMTP")))) { - char* server=server_port->as_string().cstrm(); + Value* smtp_server_port=0; + if(vmail_conf) { + // $MAIN:MAIL.SMTP[mail.yourdomain.ru[:port]] + smtp_server_port=vmail_conf->get_hash()->get(String::Body("SMTP")); + } + if(smtp_server_port) { + SMTP smtp; + char* server=smtp_server_port->as_string().cstrm(); const char* port=rsplit(server, ':'); if(!port) port="25"; smtp.Send(server, port, message_cstr, from->cstrm(), to->cstrm()); - } else - throw Exception("parser.runtime", - 0, - "$"MAIN_CLASS_NAME":"MAIL_NAME".SMTP not defined"); + return; + } + +#if WIN32 + // win32 without SMTP server configured + throw Exception("parser.runtime", + 0, + "$"MAIN_CLASS_NAME":"MAIL_NAME".SMTP not defined"); #else // unix // $MAIN:MAIL.sendmail["/usr/sbin/sendmail -t -i -f postmaster"] default @@ -206,13 +204,7 @@ static void _send(Request& r, MethodPara const String* from=0; String* to=0; const String& message= - GET_SELF(r, VMail).message_hash_to_string(r, hash, 0, from, -#ifdef WIN32 - true -#else - false -#endif - , to); + GET_SELF(r, VMail).message_hash_to_string(r, hash, 0, from, to); //r.write_pass_lang(message); sendmail(r, message, from, to, soptions);