--- parser3/src/classes/smtp/Attic/smtp.C 2002/02/08 08:30:11 1.9 +++ parser3/src/classes/smtp/Attic/smtp.C 2002/12/05 15:00:01 1.18 @@ -4,14 +4,16 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: smtp.C,v 1.9 2002/02/08 08:30:11 paf Exp $ - Parts of the code here is based upon an early gensock and blat */ +static const char* IDENT_SMTP_C="$Date: 2002/12/05 15:00:01 $"; + #include "pa_exception.h" #include "smtp.h" +//#define DEBUG_SHOW + SMTP::SMTP(Pool& pool, const String& aorigin_string) : Pooled(pool), origin_string(aorigin_string) { the_socket = 0; @@ -56,7 +58,7 @@ ConnectToHost(const char *hostname, cons CloseConnect(); - throw Exception(0, 0, + throw Exception("smtp.connect", &origin_string, "connect to %s:%s failed", hostname, service); @@ -222,7 +224,7 @@ SendLine(const char *data, unsigned long while( length > 0 ) { if( SOCKET_ERROR == select(0, NULL, &fds, NULL, &timeout) ) - throw Exception(0, 0, + throw Exception("smtp.execute", &origin_string, "connection::put_data() unexpected error from select: %d", WSAGetLastError()); @@ -247,7 +249,7 @@ SendLine(const char *data, unsigned long break; default: - throw Exception(0, 0, + throw Exception("smtp.execute", &origin_string, "connection::put_data() unexpected error from send(): %d", ws_error); @@ -321,7 +323,7 @@ SendSmtpError(const char * message) SendLine("QUIT\r\n", 6); CloseConnect(); - throw Exception(0, 0, + throw Exception("smtp.execute", &origin_string, "failed: %s", message); } @@ -342,8 +344,6 @@ transform_and_send_edit_data(const char send_len = lstrlen(editptr); index = editptr; - header_end = strstr(editptr, "\r\n\r\n"); - while( !done ) { // room for extra char for double dot on end case @@ -353,22 +353,17 @@ transform_and_send_edit_data(const char { case '.': if( previous_char == '\n' ) - { - /* send _two_ dots... */ - SendBuffer(index, 1); - } + SendBuffer(index, 1); // send _two_ dots... SendBuffer(index, 1); break; - case '\r': - // watch for soft-breaks in the header, and ignore them - if( index < header_end && (strncmp(index, "\r\r\n", 3) == 0) ) - index += 2; - else - if( previous_char != '\r' ) - SendBuffer(index, 1); - // soft line-break (see EM_FMTLINES), skip extra CR */ + case '\n': // x\n -> \r\n + if( previous_char != '\r' ) { + SendBuffer("\r", 1); + SendBuffer(index, 1); + } break; + default: SendBuffer(index, 1); break; @@ -413,7 +408,7 @@ open_socket( const char *server, const c ConnectToHost(server, service); if( gethostname(my_hostname, sizeof(my_hostname)) ) - throw Exception(0, 0, + throw Exception("smtp.connect", &origin_string, "lookup of '%s' failed", my_hostname); } @@ -464,7 +459,7 @@ prepare_message(char *from, char *to, co SendLine(out_data, lstrlen(out_data) ); if( 250 != get_line() ) - throw Exception(0, 0, + throw Exception("smtp.execute", &origin_string, "The mail server doesn't like the name %s. Have you set the 'To: ' field correctly?", ptr); @@ -501,12 +496,6 @@ static char *rsplit(char *string, char d } return NULL; } -static char *extractEmail(char *email) { - lsplit(email, '>'); lsplit(email, '\x0D');lsplit(email, '\x0A'); - char *next=rsplit(email, '<'); - if(next) email=next; - return email; -} //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- @@ -516,7 +505,11 @@ static char *extractEmail(char *email) { void SMTP:: Send(const char *server, const char *service, const char *msg, char *from, char *to) { - prepare_message( extractEmail(from), extractEmail(to), server, service); +#ifdef DEBUG_SHOW + throw Exception("paf.debug",0,"from=%s|to=%s|msg=%s", from,to,msg); +#endif + + prepare_message( from, to, server, service); send_data(msg);