SMTP Fails FWH 9.12 / xHarbour Nov 09

SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby TimStone » Fri Feb 26, 2010 2:31 am

I have had a working email SMTP program without problems using FWH 9.5 and xHarbour May 09.

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



 
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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby Antonio Linares » Fri Feb 26, 2010 7:33 pm

Tim,

Do you get the "finished" msg ?

We get the MsgInfo( "finished" ) properly shown
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby TimStone » Fri Feb 26, 2010 7:48 pm

Yes, but it doesn't actually send the emails. On the MsgBar I get only the message that it is attempting to connect.

The frustration is that the exact same code worked in the earlier FWH 9.05 and xHarbour (.com) May 2009.

Also, I am not getting an smtp.log file ... which would help.
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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby Antonio Linares » Fri Feb 26, 2010 11:38 pm

Tim,

There is a fix required for winsock.c in these lines: ("v" is missing in ...stor... calls)
Code: Select all  Expand view

   if( wLen < 10000 )  // socket errors = 10000 + ...
      hb_storvclen( ( char * ) buffer, wLen, 2 );
   else
      hb_storvclen( "", 0, 2 );
 

once that code is changed, if you remove this line in your example:
Code: Select all  Expand view

    // oInit := TSmtp():New( cHost, mailport, mailauth , mailuser, mailpass )
 

then the log file is generated and I get this:
Code: Select all  Expand view

02/27/10 00:32:46: Connect  Socket handle:       240   
02/27/10 00:32:46: Write    Socket handle:       240   
02/27/10 00:32:48: Read Socket handle:       240   
02/27/10 00:32:48: 220-phoenix.lunarpages.com ESMTP Exim 4.69 #1 Fri, 26 Feb 2010 15:32:47 -0800
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
   
02/27/10 00:32:48: Read Socket handle:       240   
02/27/10 00:32:48: 250 phoenix.lunarpages.com Hello 253.199.222.87.dynamic.jazztel.es [87.222.198.242]
   
02/27/10 00:32:49: Read Socket handle:       240   
02/27/10 00:32:49: 503 AUTH command used when not advertised
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby TimStone » Sat Feb 27, 2010 12:54 am

I'm using xHarbour Builder and having a problem building Winsock.c
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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby Daniel Garcia-Gil » Sat Feb 27, 2010 1:05 am

Tim...

maybe you need the prototypes to xharbour, you can copy at the end your main prg

this code was got from fwh\source\function\harbour.prg

Code: Select all  Expand view

#ifdef __XHARBOUR__

// Keep this C code here so only xHarbour uses it

#pragma BEGINDUMP

//char * hb_parc( int iParam, ... );
//ULONG  hb_parclen( int iParam, ... );
//int    hb_parni( int iParam, ... );
//LONG   hb_parnl( int iParam, ... );
//int    hb_parl( int iParam, ... );
//void   hb_storc( const char * szText, int iParam, ... );
//void   hb_storclen( const char * szText, ULONG ulLength, int iParam, ... );
//void   hb_storl( int iLogical, int iParam, ... );
//void   hb_storni( int iValue, int iParam, ... );
//void   hb_stornl( LONG lValue, int iParam, ... );
//void   hb_stords( const char * szDate, int iParam, ... );
//void   hb_stornd( double dValue, int iParam, ... );

char * hb_parvc( int iParam, int iIndex )
{
   return ( char * ) hb_parc( iParam, iIndex );
}  

ULONG hb_parvclen( int iParam, int iIndex )
{
   return hb_parclen( iParam, iIndex );
}

int hb_parvni( int iParam, int iIndex )
{
   return hb_parni( iParam, iIndex );
}  

long hb_parvnl( int iParam, int iIndex )
{
   return hb_parnl( iParam, iIndex );
}  

BOOL hb_parvl( int iParam, int iIndex )
{
   return hb_parl( iParam, iIndex );
}  

void hb_storvc( char * szText, int iParam, int iIndex )
{
   hb_storc( szText, iParam, iIndex );
}  

void hb_storvclen( char * szText, ULONG ulLength, int iParam )
{
   hb_storclen( szText, ulLength, iParam );
}  

void hb_storvl( BOOL bValue, int iParam, int iIndex )
{
   hb_storl( bValue, iParam, iIndex );
}  

void hb_storvnl( LONG lValue, int iParam, int iIndex )
{
   hb_stornl( lValue, iParam, iIndex );
}  

void hb_storvni( int iValue, int iParam, int iIndex )
{
   hb_storni( iValue, iParam, iIndex );
}

void hb_storvds( char * szDate, int iParam, int iIndex )
{
   hb_stords( szDate, iParam, iIndex );
}    

void hb_storvnd( double dValue, int iParam, int iIndex )
{
   hb_stornd( dValue, iParam, iIndex );
}    

#pragma ENDDUMP

#endif

 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby TimStone » Sat Feb 27, 2010 2:37 am

Sorry but I'm just getting more of a mess ....

I need the corrected winsock.obj file ....
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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby Antonio Linares » Sun Feb 28, 2010 10:22 am

Tim,

I already emailed you the OBJ. What was the result ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby TimStone » Mon Mar 01, 2010 3:08 pm

It is still not working for me. No log, no transmission.
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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby Antonio Linares » Mon Mar 01, 2010 5:43 pm

Tim,

Have you removed this line ?

// oInit := TSmtp():New( cHost, mailport, mailauth , mailuser, mailpass )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby TimStone » Mon Mar 01, 2010 5:51 pm

Yes
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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby byte-one » Tue Mar 02, 2010 4:38 pm

Now I also test SMTP with xharbour and 9.08. I found, that the mails are going out, but the messages "connected" and "sent" are not shown. In harbour and 9.08 all is ok! Without oInit in both cases no mails are sent!!
Antonio, any solution?
Last edited by byte-one on Tue Mar 02, 2010 6:15 pm, edited 1 time in total.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby Antonio Linares » Tue Mar 02, 2010 5:37 pm

Günther,

What SMTP example are you using ? FWH\samples\TestSmtp.prg ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby Antonio Linares » Tue Mar 02, 2010 5:44 pm

FWH\samples\TestSmtp.prg is working fine with both Harbour and xHarbour and FWH 10.2
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: SMTP Fails FWH 9.12 / xHarbour Nov 09

Postby byte-one » Tue Mar 02, 2010 6:14 pm

Antonio, you use in the example:
oOutMail:bConnected = { || oWnd:SetMsg( "Connected" ) }

and i use:
oOutMail:bConnected = { || (cV := "Connected", oSay:refresh()) }
where cV is the variable from the say-object
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Marc Venken and 92 guests