TMailManager():New()
oServer:SetUseSSL( .F. )
oServer:SetUseTLS( .F. )
if nSendSec == 0
nSendPort := 25 //default port for SMTP protocol
elseif nSendSec == 1
nSendPort := 465 //default port for SMTP protocol with SSL
oServer:SetUseSSL( .T. )
else
nSendPort := 587 //default port for SMTPS protocol with TLS
oServer:SetUseTLS( .T. )
endif
// once it will only send messages, the receiver server will be passed as ""
// and the receive port number won't be passed, once it is optional
xRet := oServer:Init( "", cSendSrv, cUser, cPass, , nSendPort )
if xRet != 0
cMsg := "Could not initialize SMTP server: " + oServer:GetErrorString( xRet )
conout( cMsg )
return
endif
// the method set the timout for the SMTP server
xRet := oServer:SetSMTPTimeout( nTimeout )
if xRet != 0
cMsg := "Could not set " + cProtocol + " timeout to " + cValToChar( nTimeout )
conout( cMsg )
endif
// estabilish the connection with the SMTP server
xRet := oServer:SMTPConnect()
if xRet <> 0
cMsg := "Could not connect on SMTP server: " + oServer:GetErrorString( xRet )
conout( cMsg )
return
endif
// authenticate on the SMTP server (if needed)
xRet := oServer:SmtpAuth( cUser, cPass )
if xRet <> 0
cMsg := "Could not authenticate on SMTP server: " + oServer:GetErrorString( xRet )
conout( cMsg )
oServer:SMTPDisconnect()
return
endif
oMessage := |