PureSMTP library : mail & attachments (AUTH supported)
Moderator: gnozal
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
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
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Currently only AUTH LOGIN.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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
I get Invalid mem access (read error at address 0) in line 19 here:
PB4.10B4.
Notice that without attachments it works nice!
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!
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Do you have Vista ... ?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!
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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
This does happen, no understandable reason why though - very strange.PureSMTP seems to crash on Vista if base64 encoding is used (auth login or attachments).
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?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Here a test EXE : http://freenet-homepage.de/gnozal/PureSMTP_VISTA.zipDoubleDutch wrote:This does happen, no understandable reason why though - very strange.PureSMTP seems to crash on Vista if base64 encoding is used (auth login or attachments).
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?
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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
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:
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
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
That's weird ... I didn't change anything (compiled 25 APR 2007) ! Maybe Vista has changed ?DoubleDutch wrote:I've been doing some tests and the latest version of your lib works (so does the vista test program).
Not here with WinNT4, it says 'Authentication unsuccesful'.DoubleDutch wrote:But if you enter the wrong password both the lib crashes and your vista test app crashes
Line 434 is the base64 DLL function call ... Could you test with your own base64 code in the DLL ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
I just tested your code (with other settings / files), no problem here.Psychophanta wrote:Sorry for the delay but no Vista, but Windows XP SP2 here.
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 ...Psychophanta wrote:I forgot: please add also SSL auth to be able to send messages using gmail for example
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Looks like it may be either a PureBasic bug or a bug with Vista?
Very strange, anyhow I've posted it to bugs.
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$)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
The bug is:
it should be...
Because PokeS writes a trailing zero at the end. Vista memory protection must be more "picky" than XP and below.
(Thanks to "jpd" for helping me figure it out.)
Edit: ABBKlaus suggests +2 for unicode...
Code: Select all
*B64EncodeBufferA = AllocateMemory(InputBufferLength)
Code: Select all
*B64EncodeBufferA = AllocateMemory(InputBufferLength+1)
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...
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
That makes sense.DoubleDutch wrote:The bug is:
it should be...Code: Select all
*B64EncodeBufferA = AllocateMemory(InputBufferLength)
Because PokeS writes a trailing zero at the end. Vista memory protection must be more "picky" than XP and below.Code: Select all
*B64EncodeBufferA = AllocateMemory(InputBufferLength+1)
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)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Thanks. As soon as you put an update online I'll check it on Vista for you. 

https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system