Enrico,
Please you can set an example for sendmail (...), for the case of using cServer ?
#include "Fivewin.ch"
STATIC hDll
FUNCTION MAIN()
LOCAL cFrom := "joao@pleno.com.br"
LOCAL cServer := "smtp.pleno.com.br"
LOCAL cTo := "joao@pleno.com.br"
LOCAL cSubjeCt := "Test with sendmail.dll"
LOCAL cMessage := "Test with sendmail.dll - Email Body"
LOCAL cSender := "joao@pleno.com.br"
LOCAL cUser := "joao@pleno.com.br"
LOCAL cPassword := "xxxx999"
LOCAL aAttach := {}
LOCAL aCc := "" //???
LOCAL lHtml := .F.
LOCAL cPort := "587"
LOCAL lNotification := .F. // cFrom
LOCAL lRet
lRet := SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, cSender, cUser, cPassword, aAttach, aCc, lHtml, cPort, lNotification )
IF lRet
? "Message sent successfully"
ELSE
? "Unsent message check windows live mail"
ENDIF
RETURN NIL
FUNCTION SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, cSender, cUser, cPassword, aAttach, aCc, lHtml, cPort, lNotification )
LOCAL cMsgFile := CTEMPFILE()
LOCAL cCmd := "SndMail -f " + cFrom + " -X " + cServer + " -r " + cTo + " -s " + ["] + cSubject + ["] + " -b " + cMsgFile
LOCAL nRes
LOCAL i
DEFAULT lHtml := "<html" $ LOWER( cMessage )
MEMOWRIT( cMsgFile, cMessage + CRLF )
IF !EMPTY( aAttach )
FOR i = 1 TO LEN( aAttach )
cCmd += " -a " + ["] + aAttach[ i ] + ["]
NEXT
ENDIF
IF !EMPTY( cSender )
cCmd += " -F " + ["] + cSender + ["]
ENDIF
IF !EMPTY( cUser )
cCmd += " -h LOGIN -u " + cUser
ENDIF
IF !EMPTY( cPassword )
cCmd += " -p " + cPassword
ENDIF
IF !EMPTY( aCc )
FOR i = 1 TO LEN( aCc )
cCmd += " -c " + ["] + aCc[ i ] + ["]
NEXT
ENDIF
IF lHtml
cCmd += " -H"
ENDIF
IF !EMPTY( cPort )
cCmd += " -P " + cPort
ENDIF
IF !EMPTY( lNotification )
cCmd += " -t " + ["] + "Disposition-Notification-To: " + cFrom + ["]
ENDIF
hDLL = LOADLIBRARY( "sndmail.dll" )
IF hDll = 0
? [Install sendmail.dll.. ]
__QUIT()
ELSE
SMTPLIBOPEN() // OPEN sndmail.dll
ENDIF
nRes = SMTPSENDMAIL( cCmd )
SMTPLIBCLOSE()
FREELIBRARY( hDLL )
FERASE( cMsgFile )
RETURN nRes = 0
DLL STATIC FUNCTION SMTPLIBOPEN() AS VOID;
PASCAL FROM "USmtpLibOpen" LIB hDll
DLL STATIC FUNCTION SMTPSENDMAIL( cCmd AS STRING ) AS LONG;
PASCAL FROM "USmtpCmdLineSendMail" LIB hDll
DLL STATIC FUNCTION SMTPLIBCLOSE() AS VOID;
PASCAL FROM "USmtpLibClose" LIB hDll
// END OF PROGRAM
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 50 guests