FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour SMTP Inconsistent result - ideas ?
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
SMTP Inconsistent result - ideas ?
Posted: Thu Oct 28, 2010 04:35 PM

First, I cannot provide a piece of code that reproduces this problem because it works fine on my computer. What I am seeking is ideas on where I can look on my clients computer to resolve this problem.

I have an element in my program that sends emails via SMTP. On my test machine it works perfectly. On some of my clients' computers it works fine.

With some of the computers, we see the "connected" message, but then when oMail:SendMail( ) , it may hang up because it apparently does not receive the response from the email server. Outlook, on that computer, configured the same way works perfectly.

I would assume the response may be getting blocked. Is there a port that might be blocked by a firewall ?

I really don't think this is a coding problem, but I would appreciate any ideas you share from your experiences.

I'm using xHarbour (.com) with FWH 10.6.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: SMTP Inconsistent result - ideas ?
Posted: Thu Oct 28, 2010 06:02 PM

Tim,

Have you tried turning on oSocket:lDebug? This logs all the communications. I think you will have to modify TSMTP since it creates the socket object and there seems to be no way to turn on oSocked:lDebug without modifying the TSMTP source. It really should have its own switch.

Also, some SMTP servers require that you be logged into the internet on the same ISP or you cannot use the SMTP server.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: SMTP Inconsistent result - ideas ?
Posted: Thu Oct 28, 2010 11:22 PM

Duh...

oMail:oSocket:lDebug := .T.

Regards,
James

PS: I need a double shot latte...

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: SMTP Inconsistent result - ideas ?
Posted: Fri Oct 29, 2010 10:14 PM

James,

Lets connect one day and I'll buy you that Latte ...

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Re: SMTP Inconsistent result - ideas ?
Posted: Sun Oct 31, 2010 10:29 AM

Timm

I suggest you this sample from asnker:

#Include "FiveWin.ch"

Function Main()
    Local oEmailCfg,oEmailMsg

    TRY
       oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
      WITH OBJECT  oEmailCfg:Fields
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value :=   "mail.xxxxxxxx.com"
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value :=  25
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2   // Remote SMTP = 2, local = 1
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value :=   .T.
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value :=  .F.
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value :=  "xxanser@xxxxxxxx.com"
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value :=  "xxxxxx"
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 30
         :Update()
      END WITH
    CATCH oError
      MsgInfo( "Could not create message configuration" + ";"  + ;
             "Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
             "SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
             "OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
             "SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
             "Message: " + oError:Description )
       Return .F.
    END
    oError:=NIL


    TRY
     oEmailMsg := CREATEOBJECT ( "CDO.Message" )
     WITH OBJECT oEmailMsg
        :Configuration =  oEmailCfg
        :From = chr(34)+" Anser K.K. "+chr(34)+ "<anser@xxxxxxxx.com>" // This will be displayed in the From (The email id does not appear)
        :To = "xxanserkk@xxxxx.com"    // <-----   Place the TO email address
        :Subject =  "This is a Tst message"
        :ReplyTo =  "xxanser@xxxxxxxxx.com"
        :Sender =  "xxanser@xxxxxxxxx.com"  // Read Receipt message is send to this
        :Organization =  "My xxxxxx Company"    // "My Company Name"
        :HTMLBody =  "<HTML> Hello  </HTML>"
        :Send()
     END WITH
     SysRefresh()
    CATCH oError

       MsgInfo( "Could not send message" + ";"  + CRLF+ ;
         "Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + CRLF+;
         "SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + CRLF+ ;
         "OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + CRLF +;
         "SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" +CRLF+ ;
         "Message: " + oError:Description )
       Return .F.

    END
    MsgInfo("Email Send")

Return
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: SMTP Inconsistent result - ideas ?
Posted: Thu Nov 11, 2010 12:13 AM

By using the logging procedure I was finally able to see what was going on, and the error code returned by the system ... and resolve the problem.

Thanks for the suggestion.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit

Continue the discussion