Harbour trunk of a couple of days ago, compiled with bcc 5.5 Using hb_sendmail(....) I get in the mail server log: 2009-11-19 23:09:57 SMTP connection from [XXXXX] (TCP/IP connection count = 1) 2009-11-19 23:09:58 SMTP protocol synchronization error (input sent without waiting for greeting): rejected connection from H=YYYYYY [XXXXXX] input="EHLO tipClientSMTP\r\nQUIT\r\n"
This means that hb_sendmail->TipClientSMTP -> TipClient are sending bytes before the server introduces itself with a 220 message that I believe is mandatory ! The server can be out of service and can announce itself with a 5xx error.... So it looks like there is a missing ::GetOk() in OpenSecure and Open.... Something like: METHOD Open( cUrl, lTLS ) CLASS tIPClientSMTP IF ! ::super:Open( cUrl ) RETURN .F. ENDIF IF ! ::GetOk() // Wait for the inital banner from the server RETURN .F. ENDIF DEFAULT lTLS TO .F. If I set timeouts to 10 seconds (1 second is way to low as a default, btw) add this code to Open and OpenSecure everythings seems to work.... But looking at some debug output I put in the code, there is something strange.... In OpenSecure: 00000081 196.01771545 [428] InetSendAll: EHLO tipClientSMTP 00000082 196.04241943 [428] GetOk: 250-YYYY Hello XXX [XXX] 00000083 196.04264832 [428] GetOk: 250-SIZE 33554432 00000084 196.04287720 [428] GetOk: 250-PIPELINING 00000085 196.04298401 [428] GetOk: 250 HELP "250-" means that there are more 250 codes coming "250 " means it is the last one... 00000086 206.04336548 [428] GetOk: 00000087 216.04341125 [428] GetOk: A couple of GetOk that end in timeout... 20 seconds later... 00000088 216.04345703 [428] InetSendAll: QUIT Then in Open: 00000092 217.12054443 [428] InetSendAll: HELO tipClientSMTP 00000093 217.14497375 [428] GetOk: 250 mail.tours.it Hello adsl203-144-114.mclink.it [213.203.144.114] The server answers immediately but the program waits 10 seconds (the timeout) in another GetOk.... which one !? 00000094 227.16149902 [428] GetOk: 00000095 227.16178894 [428] InetSendAll: MAIL FROM: <fatt...@xxx> 00000096 227.18704224 [428] GetOk: 250 OK 00000097 227.18734741 [428] InetSendAll: RCPT TO: <sen...@xxxx> 00000098 227.21192932 [428] GetOk: 250 Accepted Here it seems to be ok, also after the DATA part.... So I added: ELSEIF "PLAIN" $ oInMail:cReply lAuthPlain := .T. #if defined( HB_HAS_OPENSSL ) ELSEIF "STARTTLS" $ oInMail:cReply lAuthTLS := .T. #endif ELSEIF Left( oInMail:cReply, 4 ) == "250 " EXIT ENDIF ENDDO Some rows later, I remmed this loop since it does nothing... and GetOk() is already called in Open()... It works OK as a proof of concept but here the server is responding to a HELO message and there MAY be multiline 250 messages, like for EHLO message... // DO WHILE .T. // IF ! oInMail:GetOk() // EXIT // ENDIF // IF oInMail:cReply == NIL // EXIT // ENDIF // ENDDO It's too late this evening, tomorrow I will change this part to a loop that checks for "250 " starting to check from tha already filled cReply (for one line 250....) FINALLY: there are some small problems in hb_sendmail implementation... and the first one that started my review should create problems to almost every user that connect to a non-local mail server..... - it doesn't fully respect handling return codes (it doesn't understand when there are no more replies to wait for) - it's said that User/Password/pop3 server are mandatory but I didn't specifieed them (I don't need them!) - I believe lAuth default value should be set depending on the presence of User/password... but I should study the code a bit more.... Francesco _______________________________________________ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour