when I try to send e-Mails with tsmp-class when authentification is required, no e-Mail will be send. Following code am I using (modified testsmtp.prg):
- Code: Select all Expand view
function SendMail()
local oOutMail, cIP
local cHost := "smtp.strato.de"
local cEmail := "test@ctosoftware.de"
local cUser := "test"
local cPass := "test"
oWnd:SetMsg( "Sending Internet email..." )
WSAStartup()
oOutMail := TSmtp():New( cIP := GetHostByName( cHost ), 25 , .t., cUser, cPass )
oOutMail:bConnecting = {|| msginfo("connecting...")} //{ || oWnd:SetMsg( "Connecting to "+cHost ) }
oOutMail:bConnected = {|| msginfo("connected!")}
oOutMail:bDone = {|| msginfo("done!")}
oOutMail:bFailure = {|| msginfo("error detected!")}
oOutMail:lAuth := .t.
oOutMail:lDoAuth := .t.
oOutMail:SendMail( cEmail,; // From
{ "kuhnert@ctosoftware.de" },; // To
"It is working!!!",; // Msg Text
"Testing FiveWin Class TSmtp enhancements",; // Subject
) // attached files
oOutMail:End()
msginfo("oOutmail closed")
return nil
The msginfo "connecting..." does appear, but after that, the msginfo "oOutmail closed" directly appears, without sending an e-mail...
The statements oOutmail:lAuth = .t. and oOutmail:lDoAuth = .t. seem to be needed because a small error in the new-method of tsmtp-class:
- Code: Select all Expand view
METHOD New( cIPServer, nPort, lAuth, cUser, cPassword ) CLASS TSmtp
#ifdef __XPP__
#undef New
#endif
Default nPort := 25, ;
lAuth := .F., ; // IBTC
cUser := "", ; // [jlalin]
cPassword := "" // [jlalin]
If Empty( cIPServer ) // nil or ""
cIPServer := "0.0.0.0"
Endif
::lAuth := .F. // <<----- Here lAuth is set to .f. irrespective of the
// lAuth-parameter coming through the call of the new()-method
::lDoAuth := lAuth // IBTC
::cUser := AllTrim( cUser ) // [jlalin]
::cPassword := AllTrim( cPassword ) // [jlalin]
::oSocket := TSocket():New( nPort )
::oSocket:bRead := {|o,n| ::OnRead( o, n ) }
::oSocket:bConnect := {|o,n| ::OnConnect( o, n ) } // lkm - see adjustment to TSocket class
// by lkm now you can provide either the IPAddress or the server name (friendly name)
::cIPServer := If( IsAlpha( cIPServer ), GetHostByName( AllTrim( cIPServer ) ), cIPServer )
::nStatus := ST_INIT
// predefined events actions
::bDone := {|| MsgInfo( ;
"Message successfully sent through " + ::cIPServer + CRLF + ;
GetHostByAddress( ::cIPServer ), MSG_CAPTION ) }
::bFailure := {|| ;
MsgStop( "Session did not complete successfully" + CRLF + CRLF + ::cError, MSG_CAPTION ) }
::lTxtAsAttach := .T. // force text files as attachments, not inline
return Self