2012-01-09 22:20 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/hbtip/sendmail.prg
* contrib/hbtip/smtpcli.prg
! After a conversation with Antonio Maniero (also subscriber of the
dev-list), we detected some trouble with hb_sendmail() under some
conditions:
EXIM servers refuse the HELO/EHLO greeting that doesn't conform to
RFC2821, so when one try to autenticate with username containing an @
or any other character that is not allowed in FQDNs, the server
refuses to proceed. Many SMTP servers, (EG: Google ones) are more
tolerant, so I believe that this helped the problem gets unnoticed.
The patch introduces a new parameter, preserving backward
compatibility and at the same time fixing the @ problem, even in
unmodified code that doesn't provide the extra parameter (as we
removed the cUser from the HELO string, that is causing trouble with
EXIM. Anyway, these strings would be accepted only by tolerant
servers, so the correct one should cause no problem at all).
; Patch and description by Carlos Bacco. Thank you.
This commit is contained in:
@@ -16,6 +16,25 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2012-01-09 22:20 UTC+0100 Viktor Szakats (harbour syenar.net)
|
||||
* contrib/hbtip/sendmail.prg
|
||||
* contrib/hbtip/smtpcli.prg
|
||||
! After a conversation with Antonio Maniero (also subscriber of the
|
||||
dev-list), we detected some trouble with hb_sendmail() under some
|
||||
conditions:
|
||||
EXIM servers refuse the HELO/EHLO greeting that doesn't conform to
|
||||
RFC2821, so when one try to autenticate with username containing an @
|
||||
or any other character that is not allowed in FQDNs, the server
|
||||
refuses to proceed. Many SMTP servers, (EG: Google ones) are more
|
||||
tolerant, so I believe that this helped the problem gets unnoticed.
|
||||
The patch introduces a new parameter, preserving backward
|
||||
compatibility and at the same time fixing the @ problem, even in
|
||||
unmodified code that doesn't provide the extra parameter (as we
|
||||
removed the cUser from the HELO string, that is causing trouble with
|
||||
EXIM. Anyway, these strings would be accepted only by tolerant
|
||||
servers, so the correct one should cause no problem at all).
|
||||
; Patch and description by Carlos Bacco. Thank you.
|
||||
|
||||
2012-01-09 16:18 UTC+0100 Viktor Szakats (harbour syenar.net)
|
||||
* contrib/hbssl/ssl.c
|
||||
* contrib/hbssl/sslctx.c
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
FUNCTION hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, ;
|
||||
aFiles, cUser, cPass, cPopServer, nPriority, lRead, ;
|
||||
xTrace, lPopAuth, lNoAuth, nTimeOut, cReplyTo, ;
|
||||
lTLS, cSMTPPass, cCharset, cEncoding )
|
||||
lTLS, cSMTPPass, cCharset, cEncoding, cClientHost )
|
||||
/*
|
||||
cServer -> Required. IP or domain name of the mail server
|
||||
nPort -> Optional. Port used my email server
|
||||
@@ -78,8 +78,10 @@ FUNCTION hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, ;
|
||||
If a block is passed, it will be called for each log event with the message a string, no param on session close.
|
||||
lPopAuth -> Optional. Do POP3 authentication before sending mail.
|
||||
lNoAuth -> Optional. Disable Autentication methods
|
||||
nTimeOut -> Optional. Number os ms to wait default 20000 (20s)
|
||||
nTimeOut -> Optional. Number os ms to wait default 10000 (10s)
|
||||
cReplyTo -> Optional.
|
||||
cClientHost-> Optional. Domain name of the SMTP client in the format smtp.example.com OR client IP surrounded by brackets as in [200.100.100.5]
|
||||
Note: This parameter is optional for backwards compatibility, but should be provided to comply with RFC 2812.
|
||||
*/
|
||||
|
||||
LOCAL cTmp
|
||||
@@ -228,7 +230,7 @@ FUNCTION hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, ;
|
||||
oUrl:cFile := cTo + iif( Empty( cCC ), "", "," + cCC ) + iif( Empty( cBCC ), "", "," + cBCC )
|
||||
|
||||
BEGIN SEQUENCE
|
||||
oInmail := tIPClientSMTP():New( oUrl, xTrace )
|
||||
oInmail := tIPClientSMTP():New( oUrl, xTrace, NIL, cClientHost )
|
||||
RECOVER
|
||||
lReturn := .F.
|
||||
END SEQUENCE
|
||||
@@ -293,7 +295,7 @@ FUNCTION hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, ;
|
||||
ENDIF
|
||||
|
||||
BEGIN SEQUENCE
|
||||
oInmail := tIPClientSMTP():New( oUrl, xTrace )
|
||||
oInmail := tIPClientSMTP():New( oUrl, xTrace, NIL, cClientHost )
|
||||
RECOVER
|
||||
lReturn := .F.
|
||||
END SEQUENCE
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
CREATE CLASS tIPClientSMTP FROM tIPClient
|
||||
|
||||
METHOD New( oUrl, xTrace, oCredentials )
|
||||
METHOD New( oUrl, xTrace, oCredentials, cClientHost )
|
||||
METHOD Open( cUrl, lTLS )
|
||||
METHOD Close()
|
||||
METHOD Write( cData, nLen, bCommit )
|
||||
@@ -84,16 +84,18 @@ CREATE CLASS tIPClientSMTP FROM tIPClient
|
||||
HIDDEN:
|
||||
|
||||
VAR isAuth INIT .F.
|
||||
VAR cClientHost
|
||||
|
||||
ENDCLASS
|
||||
|
||||
METHOD New( oUrl, xTrace, oCredentials ) CLASS tIPClientSMTP
|
||||
METHOD New( oUrl, xTrace, oCredentials, cClientHost ) CLASS tIPClientSMTP
|
||||
|
||||
::super:new( oUrl, iif( ISLOGICAL( xTrace ) .AND. xTrace, "smtp", xTrace ), oCredentials )
|
||||
|
||||
::nDefaultPort := iif( ::oUrl:cProto == "smtps", 465, 25 )
|
||||
::nConnTimeout := 50000
|
||||
::nAccessMode := TIP_WO // a write only
|
||||
::cClientHost := cClientHost
|
||||
|
||||
RETURN Self
|
||||
|
||||
@@ -118,7 +120,7 @@ METHOD Open( cUrl, lTLS ) CLASS tIPClientSMTP
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
::InetSendall( ::SocketCon, "HELO " + iif( Empty( ::oUrl:cUserid ), "tipClientSMTP", ::oUrl:cUserid ) + ::cCRLF )
|
||||
::InetSendall( ::SocketCon, "HELO " + iif( Empty( ::cClientHost ), "tipClientSMTP", ::cClientHost ) + ::cCRLF )
|
||||
|
||||
RETURN ::GetOk()
|
||||
|
||||
@@ -143,7 +145,7 @@ METHOD OpenSecure( cUrl, lTLS ) CLASS tIPClientSMTP
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
::InetSendall( ::SocketCon, "EHLO " + iif( Empty( ::oUrl:cUserid ), "tipClientSMTP", ::oUrl:cUserid ) + ::cCRLF )
|
||||
::InetSendall( ::SocketCon, "EHLO " + iif( Empty( ::cClientHost ), "tipClientSMTP", ::cClientHost ) + ::cCRLF )
|
||||
|
||||
RETURN ::GetOk()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user