functuon SendEmail() from errsysw_.prg:
//-------------------------------------------------------------------------------
static function SendEmail (cSubject, cBody, cMsg, oWnd, cImgFile)
LOCAL oInit, oMail, aSet, i, lOk := .f.
LOCAL lReceipt := .f.
LOCAL lAuth := .f.
LOCAL cFrom
LOCAL aAttach
LOCAL nPort := 25 // 587 (smtp-submission)
DEFAULT cMsg := nil //HTML Email
aSet := ReadIni ()
cFrom := TRIM (aSet[E_USER])+" <"+TRIM (aSet[E_FROM])+">"
FOR i := 1 TO Len (aSet)
lOk := !Empty (aSet[i])
//? aSet[i]
NEXT
// ? cFrom + CRLF+;
// aSet [E_LOGIN] + CRLF+;
// aSet [E_PASS] + CRLF+;
// aSet [E_SMTP] + CRLF+;
// aSet[E_TO] + CRLF//+;
IF ! lOk
MsgAlert ( aLang[emailALERT1], aLang[emailALERT2])
RETURN (nil)
ENDIF
FErase ("Smtp.log") // delete old logfile
if file( cImgFile )
aAttach := { cErrorPath+"error.log", cImgFile }
else
aAttach := { cErrorPath+"error.log" }
endif
oInit := TSmtp():New( aSet [E_SMTP] )
oMail := TSmtp():New( aSet [E_SMTP], nPort, lAuth, aSet [E_LOGIN], aSet [E_PASS] ) // [jlalin], IBTC
oMail:cReplyTo := aSet[E_FROM] //aSet [E_REPLYTO] //cReplyTo
oMail:nGMT := 1 // 8 = Pacific Standard Time (GMT -08:00) - Adjust this to your own Time Zone!
//oMail:lTxtAsAttach := .F. // uncomment to force txt, log and htm files as inline as opposed to attachement
oMail:nDelay := 2
oMail:oSocket:lDebug := .T. // uncomment to create log file
oMail:oSocket:cLogFile := "smtp.log"
oMail:bConnecting := {||MsgRun( aLang[emailCONNECTING1] + aSet [E_SMTP] + " (" + oMail:cIPServer + ") "+ aLang[emailCONNECTING2]) }
oMail:bConnected := {||MsgRun ( aLang[emailCONNECTED] ) }
oMail:SendMail( ;
cFrom, ; // from/de
{ aSet[E_TO] }, ; // to/para (arreglo) - I use cSender here also because it's an "autotest". Actually you would type a different address here
cBody,; // Body/Mensaje
cSubject,; // Subject/Asunto
aAttach, ; // Array of filenames to attach/Arreglo de nombres de archivos a agregar
{ }, ; // aCC
{ }, ; // aBCC
lReceipt, ; // Return Receipt/acuse de recibo
cMsg ) // msg in HTML format/mensaje en HTML
oInit:end()
return (nil)
and email.ini:
[Email]
User=
Login=mtajkov@intersped.co.rs
Pass=********
Pop-Host=mail.intersped.co.rs
Smpt-Host=mail.intersped.co.rs
Leasedline=.F.
Autosave=.T.
Maildelete=.T.
ReplyTo=
MailTo=milos.tajkov@smartprint.co.rs
Regards,
Miloš