Now the same code does not go through. I am using FWH 9.12 and xHarbour main release of November 2009 ( xHarbour.com with xBuilder ). The following code can be compiled/linked as a standalone. The server info is accurate and can be used for testing. Feel free to build it and send it.
It is not just with this server. I have the same problem with my local server using Port 25. I'm obviously overlooking something.
Your input would be greatly appreciated.
- Code: Select all Expand view
- #include "fivewin.ch" //
#INCLUDE "wcolors.CH"
#include "common.ch"
#DEFINE HELP_FINDER
#DEFINE HKEY_LOCAL_MACHINE 2147483650
#DEFINE INTERNET_FLAG_PASSIVE 0x08000000
PROCEDURE main
LOCAL cSndTo := "TimStone@masterlinksoftware.com"
LOCAL SndFile := ""
LOCAL cSubj := "Test of email system"
LOCAL cText := "It would be nice for this to work."
PRIVATE oWnd
DEFINE WINDOW oWnd TITLE "Test ASW Email" FROM 0,0 TO 400, 600 PIXEL
SET MESSAGE OF oWnd TO " " 2007 NOINSET DATE KEYBOARD
ACTIVATE WINDOW oWnd ON INIT ASWSend( cSndTo, SndFile, cText, cSubj )
RETURN NIL
FUNCTION ASWSend( MailTo, cSndFile, cText, cSubj )
// Declare LOCAL variables
LOCAL oInit, oMail
LOCAL mailname, mailself, mailuser, mailpass, mailport, lreceipt := .F., lUseMLS := .F.
LOCAL cFrom
// Open Config File and get email setup information
mailname := "mail.masterlinksoftware.com"
mailself := "timstone@masterlinksoftware.com"
mailuser := "c10000@masterlinksoftware.com"
mailpass := "drmls82"
mailport := 587
mailauth := .T.
cSender := ALLTRIM( mailuser )
cHost := ALLTRIM( mailname )
cMailTo := ALLTRIM( MailTo )
aFiles := { cSndFile }
// initialize sockets (or nothing will happen) - it's a quirk in GetHostByName(), not TSmtp
oInit := TSmtp():New( cHost, mailport, mailauth , mailuser, mailpass )
// now let's go for our socket
oMail := TSmtp():New( cHost, mailport, mailauth , mailuser, mailpass )
oMail:cReplyTo := mailself
oMail:nGMT := -8 // Pacific Standard Time (GMT -08:00) - Adjust this to your own Time Zone!
// Provide for a delay
oMail:nDelay := 2
// Create a log file
oMail:oSocket:lDebug := .T.
oMail:oSocket:cLogFile := "smtp.log"
// Now connect to host
oMail:bConnecting := {|| oWnd:SetMsg( "Connecting to " + cHost + " (" + oMail:cIPServer + ;
") and waiting for response..." ) }
oMail:bConnected := {|| oWnd:SetMsg( "Connected and sending mail and attachments..." ) }
oMail:bDone := { || oWnd:SetMsg( "Message sent successfully" ) }
oMail:bFailure := { || oMail:nStatus := 7 }
// Complete message and send
cMsg := "Thank You"
oMail:SendMail( cSender, { cMailTo }, cText, cSubj, aFiles, {}, {}, .F. , NIL )
oInit:end()
IF oMail <> nil
oMail:End()
ENDIF
MsgInfo( "Finished" )
RETURN NIL