SMTP session aborting
SMTP session aborting
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
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
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
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
SMTP session aborting
Yes, I'm able to send HTML, but I modified another little piece of code here
in OnRead() method
regards
Roberto Chiaiese
in OnRead() method
Code: Select all
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
Roberto Chiaiese
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
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
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- AlexSchaft
- Posts: 172
- Joined: Fri Oct 07, 2005 1:29 pm
- Location: Edenvale, Gauteng, South Africa
SMTP class
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
We have this modification:
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
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
Code: Select all
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
SMTP Class
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:
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 +*/
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
// 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"
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 +*/