SMTP session aborting

SMTP session aborting

Postby chiaiese » Fri Feb 23, 2007 2:46 pm

hello!
I have a working prg which sends email via TSMTP:SendMail() connecting to a mail server on the internet.
Now, if I upload my program to the same PC where the mail server is installed, mails are no more sent out.
I use LKM version because I need user authentication
Turned on the debug mode here is the log:

23-02-2007 15:30:43: Connect Socket handle: 7948 WSA Error: 0
23-02-2007 15:30:43: Write Socket handle: 7948 WSA Error: 0
23-02-2007 15:30:45: Read Socket handle: 7948 WSA Error: 0
23-02-2007 15:30:45: 220 mail.myserver.it ESMTP
23-02-2007 15:30:45: HELO smtp-client
23-02-2007 15:30:45: AUTH LOGIN
23-02-2007 15:30:45: Read Socket handle: 7948 WSA Error: 0
23-02-2007 15:30:45: 250 Hello.
334 VXNlcm5hbWU6

anyone can say what's happen ?
thanks
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Postby chiaiese » Fri Feb 23, 2007 4:46 pm

solved!
it seems as the socket catches two messages at a time
I don't know why there is this different behavior among the two PC's but now it works

I put the follwing modifications in the TSMTP class, OnRead() method

Case ::nStatus == ST_AUTH0
If SubStr( cData, 1, 3 ) == "250"
// add: Roberto Chiaiese - 23/02/2007 - two messages at a time
If Eval( bReply, cAns := "334" )
oSocket:SendData( cMimeEnc( ::cUser ) + CRLF )
::nStatus := ST_USER
else
// end r.c.
::nStatus := ST_AUTH
endif
Else
::nStatus := ST_QUIT
Endif

Roberto Chiaiese
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Postby Ollie » Thu May 24, 2007 1:52 pm

Hi Roberto

Are you able to send HTML messages with TSMTP?
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

SMTP session aborting

Postby chiaiese » Fri May 25, 2007 8:22 am

Yes, I'm able to send HTML, but I modified another little piece of code here
in OnRead() method

Code: Select all  Expand view
If ! Empty( ::cHTML )  // RRG 29.05.2002 Send as HTML sytle email (Cambios para enviar correo como html)
    oSocket:SendData( CRLF + "--NextPart" + CRLF + ;
                  "Content-Type: text/html; " +;
                  'charset="iso-8859-1"' + CRLF + ;
                  /* "Content-Transfer-Encoding: quoted-printable" + CRLF +*/ CRLF + ;
                  FormHtml( ::cHTML, ::cSubject, ::cMailer ) + CRLF )
                  // r.c. rem: "quoted-printable" above - 28/03/2007
            Endif


regards
Roberto Chiaiese
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Postby Ollie » Fri May 25, 2007 11:12 am

Would you mind emailing me the TMAIL class with all the changes you have made?

ollie@theoasis.co.za
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby chiaiese » Fri May 25, 2007 3:20 pm

I did not make any change to the TMail class, but only to TSmtp and only those I've mentioned above
Now it works for me with authentication and text .OR. html body


Roberto Chiaiese
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Postby Ken Wantz » Sat May 26, 2007 2:04 pm

I have 2 questions.

First, I assume ST_AUTH0, ST_USER and ST_AUTH are defiined variables but you make no mention as to their values? As these values do not appear to be set anywhere, testing them would always return a false result. A further question is whether they get set in a class other than TSMTP.prg?

Second, after what existing code are these pieces added? You mention the second piece of code modifies existing code but I am thinking it is in fact added.

Could you please clarify these 2 points for me?

Regards,

Ken
Ken Wantz
 
Posts: 45
Joined: Wed Nov 29, 2006 7:48 pm
Location: Toronto Canada

Postby James Bott » Sat May 26, 2007 6:55 pm

Roberto,

I think you must be using a non-standard FW TSMTP class. I have the latest class (FWH ver 7.05) and there is no line:

Case ::nStatus == ST_AUTH0

And ST_AUTHO and ST_USER are not defined. Also it seems that you have a typo in ST_AUTH0 - the last character is a zero not a letter O.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

SMTP class

Postby AlexSchaft » Mon May 28, 2007 6:33 am

Hi,

Not having seen your full source, I'd just like to point out that an smtp server can send multiple lines of replies, but the last line always has a space as the fourth character, while the rest have a dash, e.g.

Below from a telnet to our mail server

Code: Select all  Expand view
220 mail.quicksoftware.co.za ESMTP
ehlo alexlt
250-quicksoftware.co.za Hi pc-00174.quicksoftware.co.za [10.1.1.174]
250-PIPELINING
250-8BITMIME
250 SIZE 10000000


We have this modification:

Code: Select all  Expand view
METHOD OnRead( oSocket ) CLASS qSmtp

  // Buffer received data, as you do not necessarily receive all the server data in one go e.g.
  ::cReceived                += cData  // cReceived is built up until it is a complete server response

  // Pull out full lines received
  Do While at(CRLF, ::cReceived) > 0
    nPos                     := at(CRLF, ::cReceived)

    // Build up an array of all the server replies
    AAdd(::acReply, Left(::cReceived, nPos - 1))

    ::cReceived              := Substr(::cReceived, nPos + 2)
  Enddo

  // Has closing line been received i.e. full reply from server (may come in dribs and drabs)
  if Substr(ATail(::acReply), 4, 1) == " "
    // We now have the full server response, now process it.
    // AS 08/09/2005
    cReply                   := Substr(ATail(::acReply), 1, 3)

    if ::lLog
      // AS 08/09/2005
      aeval(::acReply, {|pcReply| LogFile(::cLogFile, {"SERVER: " + pcReply})})
//      LogFile(::cLogFile, {"MAILSERVER (Status = " + NTRIM(::nStatus)+"): " + cReply})
    endif

    do case
      case ::nStatus == ST_INIT
        if cReply == "220" // Server asknowleges connection

          // Send helo and hop to next status
          ::nStatus          := ST_CONNECTED
User avatar
AlexSchaft
 
Posts: 172
Joined: Fri Oct 07, 2005 1:29 pm
Location: Edenvale, Gauteng, South Africa

SMTP Class

Postby chiaiese » Mon May 28, 2007 8:39 am

Hi all,
first of all, sorry for my bad english.
yes I'm using a non-standard class, I wrote it on my first message in this topic.
I'm using LKM version dated 02 june 2005.
I don't know if I can post entire code here because the source is not mine and (sorry) I don't remember where I downloaded it from.
Anyway here is the header of the class:

Code: Select all  Expand view
// FiveWin Internet outgoing mail Class
// Modified by Luis Krause July 5, 2001; February 26, 2002; October 7, 2002; November 5, 2002;
//                         October 9, 2003; June 1, 2005
//    with code from Alex Shaft, Byron Hopp, Andrew Ross (PipleLine Solutions),
//    Frank Demont, Peter Kohler, Rafael Gaona, Joaquim Ferrer,
//    Jos‚ Lal¡n, Ray Alich (IBTC), Ignacio Vizca¡no Tapia and others
// Special thanks to Jorge Mason for the fix to GetHostByAddress() that was GPFing on some servers

// Simple Authentication and Security Layer [SASL]
// This class only supports LOGIN type for authentication.
// TODO: Add PLAIN and MD5 methods.
//       PLAIN is the same as LOGIN but it doesn't use base64, i.e.:
//       AUTH LOGIN -> USER cMimeEnc( ::cUser )
//       AUTH PLAIN -> USER ::cUser
// See rfc2554.txt for more details about ESMTP
// [jlalin]

#include "FiveWin.ch"

#ifndef __CLIPPER__
#xtranslate Memory(<n>) =>                       // only needed with Clipper, not [x]Harbour
#endif

// different session status
#define ST_INIT       0
#define ST_CONNECTED  1
#define ST_RESET      2
#define ST_MAILFROM   3
#define ST_RCPTTO     4
#define ST_DATA       5
#define ST_SENT       6
#define ST_QUIT       7
#define ST_DONE       8
#define ST_ERROR      9

// Authentication states
#define ST_AUTH0      10        // IBTC
#define ST_AUTH       11        // [jlalin]
#define ST_USER       12        // [jlalin]
#define ST_PASS       13        // [jlalin]
// Last defined state
#define ST_LAST       ST_PASS   // [jlalin]

#define MSG_CAPTION   "SMTP Services"


as yu can see the constants are defined for this class only and there is no typo here as ST_AUTH0 ends with a 'zero'.

In the first piece of code in my previous messages, I added the code between the lines beginning with the remarks "add" ending with "end r.c."

In the second piece I just removed:
/* "Content-Transfer-Encoding: quoted-printable" + CRLF +*/
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 60 guests

cron