Page 13 of 25
Posted: Wed Oct 17, 2007 12:58 pm
by Kukulkan
Hi Gnozal,
Which AUTH versions does your library actual use? I have a SMTP server that denies the e-mails with the following error:
Error code 504 5.7.4 Unrecognized authentication type.
Do you only support AUTH LOGIN or do you support CRAM-MD5, too? It seems to me that some mailservers only support the MD5 method (
http://en.wikipedia.org/wiki/SMTP-AUTH).
Kukulkan
Posted: Wed Oct 17, 2007 1:10 pm
by gnozal
Kukulkan wrote:Hi Gnozal,
Which AUTH versions does your library actual use? I have a SMTP server that denies the e-mails with the following error:
Error code 504 5.7.4 Unrecognized authentication type.
Do you only support AUTH LOGIN or do you support CRAM-MD5, too? It seems to me that some mailservers only support the MD5 method (
http://en.wikipedia.org/wiki/SMTP-AUTH).
Kukulkan
Currently only AUTH LOGIN.
Posted: Tue Oct 30, 2007 4:02 pm
by Psychophanta
I get Invalid mem access (read error at address 0) in line 19 here:
Code: Select all
MySMTPServer.s="mailhost.terra.es"
MySMTPPort.l=25
If PureSMTP_OpenSMTPConnection(MySMTPServer.s,MySMTPPort.l)=#PureSMTP_Ok
Debug PureSMTP_GetLastServerMessage()
MailFrom.s="some@terra.es"
MailTo.s="any@hotmail.com"
Subject.s="Test (with attachments)"
MsgBody.s="Testing PureSMTP"
UserName.s="some.terra.es"
Password.s="blahblah"
HeaderAddon.s="Time: "+FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss",Date())
; file attachements
File1.s="D:\AL\new\PureSMTP_.zip":If FileSize(File1)<=0:File1="":EndIf
File2.s="D:\AL\new\fmts.txt":If FileSize(File2)<=0:File2="":EndIf
Separator.s="":If File1.s And File2.s:Separator=";":EndIf
Attachments.s=File1.s+Separator.s+File2.s
; sending mail
Debug Attachments
Status.l = PureSMTP_SendMail(MailTo.s,MailFrom.s,Subject.s,MsgBody.s,Attachments.s,UserName.s,Password.s,HeaderAddon.s)
If Status = #PureSMTP_Ok
Debug "Message 1 : sent"
Debug "Status = " + Str(Status)
Debug PureSMTP_GetLastServerMessage()
Else
Debug "Message 1 : something went wrong !"
Debug "Status = " + Str(Status)
Debug PureSMTP_GetLastServerMessage()
EndIf
PureSMTP_CloseSMTPConnection()
Else
Debug "OpenSMTPConnection failed"
Debug PureSMTP_GetLastServerMessage()
EndIf
PB4.10B4.
Notice that without attachments it works nice!
Posted: Tue Oct 30, 2007 4:42 pm
by gnozal
Psychophanta wrote:I get Invalid mem access (read error at address 0) in line 19 here: ...
PB4.10B4.
Notice that without attachments it works nice!
Do you have Vista ... ?
PureSMTP seems to crash on Vista if base64 encoding is used (auth login or attachments).
I have tested the code with Freak's ValidatePBHeap() function : no problem reported.
Posted: Tue Oct 30, 2007 5:02 pm
by DoubleDutch
PureSMTP seems to crash on Vista if base64 encoding is used (auth login or attachments).
This does happen, no understandable reason why though - very strange.
Could you implement some kind of callback scheme for the encoding/decoding (pure_pop3 would need it too) - so we can try get to the bottom of the problem?
This feature may be useful in any event?
Posted: Tue Oct 30, 2007 6:16 pm
by gnozal
DoubleDutch wrote:PureSMTP seems to crash on Vista if base64 encoding is used (auth login or attachments).
This does happen, no understandable reason why though - very strange.
Could you implement some kind of callback scheme for the encoding/decoding (pure_pop3 would need it too) - so we can try get to the bottom of the problem?
This feature may be useful in any event?
Here a test EXE :
http://freenet-homepage.de/gnozal/PureSMTP_VISTA.zip
1. It uses an external DLL for the base64 encoding (you can replace it with your own code)
2. The EXE is stuffed with ValidatePBHeap() calls.
Posted: Tue Oct 30, 2007 8:05 pm
by DoubleDutch
I've been doing some tests and the latest version of your lib works (so does the vista test program).
But if you enter the wrong password both the lib crashes and your vista test app crashes, here is the message from the vista test app:
PureSMTP has crashed [Error = C00000005]
'An attemped read or write to/from an address to which that process isn't allowed'
Module: C:\Purebasic400\Compilers\PB_EditorOutput2.pb ; Line 434
Posted: Tue Oct 30, 2007 9:15 pm
by Psychophanta
Sorry for the delay but no Vista, but Windows XP SP2 here.
I forgot: please add also SSL auth to be able to send messages using gmail for example

Posted: Wed Oct 31, 2007 9:16 am
by gnozal
DoubleDutch wrote:I've been doing some tests and the latest version of your lib works (so does the vista test program).
That's weird ... I didn't change anything (compiled 25 APR 2007) ! Maybe Vista has changed ?
DoubleDutch wrote:But if you enter the wrong password both the lib crashes and your vista test app crashes
Not here with WinNT4, it says 'Authentication unsuccesful'.
Line 434 is the base64 DLL function call ... Could you test with your own base64 code in the DLL ?
Posted: Wed Oct 31, 2007 9:22 am
by gnozal
Psychophanta wrote:Sorry for the delay but no Vista, but Windows XP SP2 here.
I just tested your code (with other settings / files), no problem here.
Psychophanta wrote:I forgot: please add also SSL auth to be able to send messages using gmail for example

I don't know the SSL/TLS protocol, and many apps use a third party DLL from
www.OpenSSL.org , so it doesn't look that easy ...
Posted: Wed Oct 31, 2007 10:21 am
by DoubleDutch
Looks like it may be either a PureBasic bug or a bug with Vista?
Code: Select all
; Base64.DLL
Global Result.s
Procedure.s _PureSMTP_Base64Encode(strText.s)
Protected *B64EncodeBufferA, *B64EncodeBufferB, OutputBufferLength.l, InputBufferLength.l
InputBufferLength = Len(strText)
OutputBufferLength = InputBufferLength * 2 ; et pas * 1.33 comme dans le manuel !
If OutputBufferLength < 64
OutputBufferLength = 64
EndIf
*B64EncodeBufferA = AllocateMemory(InputBufferLength)
*B64EncodeBufferB = AllocateMemory(OutputBufferLength)
CompilerIf #PB_Compiler_Unicode ;>
PokeS(*B64EncodeBufferA, strText, InputBufferLength, #PB_Ascii)
CompilerElse ;=
PokeS(*B64EncodeBufferA, strText)
CompilerEndIf ;<
Base64Encoder(*B64EncodeBufferA, InputBufferLength, *B64EncodeBufferB, OutputBufferLength)
Result = PeekS(*B64EncodeBufferB)
FreeMemory(*B64EncodeBufferA)
FreeMemory(*B64EncodeBufferB) ; <-- crashes here!!!
ProcedureReturn Result
EndProcedure
;test$=_PureSMTP_Base64Encode("ab1234567") ; <- works
test$=_PureSMTP_Base64Encode("ab123456") ; <- crashes on Vista
Debug(test$)
Very strange, anyhow I've posted it to bugs.
Posted: Wed Oct 31, 2007 12:34 pm
by DoubleDutch
The bug is:
Code: Select all
*B64EncodeBufferA = AllocateMemory(InputBufferLength)
it should be...
Code: Select all
*B64EncodeBufferA = AllocateMemory(InputBufferLength+1)
Because PokeS writes a trailing zero at the end. Vista memory protection must be more "picky" than XP and below.
An optional length parameter (in bytes) can be specified that defines the length of the string itself, a zero will still be placed in memory after the poked string (ie. specifying 6 will write 7 bytes, 6 for the string, and the last byte will be zero).
(Thanks to "jpd" for helping me figure it out.)
Edit: ABBKlaus suggests +2 for unicode...
Posted: Wed Oct 31, 2007 2:19 pm
by gnozal
DoubleDutch wrote:The bug is:
Code: Select all
*B64EncodeBufferA = AllocateMemory(InputBufferLength)
it should be...
Code: Select all
*B64EncodeBufferA = AllocateMemory(InputBufferLength+1)
Because PokeS writes a trailing zero at the end. Vista memory protection must be more "picky" than XP and below.
That makes sense.
I will change it. The stupid thing is, I did it right in other portions of the code
Code: Select all
*B64EncodeBufferA = AllocateMemory(InputBufferLength + 2)
Posted: Wed Oct 31, 2007 2:49 pm
by DoubleDutch
Thanks. As soon as you put an update online I'll check it on Vista for you.

Posted: Wed Oct 31, 2007 3:15 pm
by gnozal
Update (Both libs)
Changes :
- fixed (very) stupid bug in Base64 encoding function.