PureSMTP library : mail & attachments (AUTH supported)

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by gnozal »

Christian Uceda wrote:Gnozal I do not doubt you tried, so there is definitively something wrong somewhere, did you tried with the same version available here: "http://gnozal.ucoz.com/PureSMTP_450.zip" (7.01) and with PB version 4.50?
I just downloaded this file and tried again in threadsafe+unicode mode : it works !
Tested with PB451RC2 and this file :

Code: Select all

MySMTPServer.s = "vsmail"
MySMTPPort.l = 25
If PureSMTP_OpenSMTPConnection(MySMTPServer, MySMTPPort) = #PureSMTP_Ok
  Debug PureSMTP_GetLastServerMessage()
  MailTo.s = "xxxxxxxxxxxx.xxxxxxx@xxxxxxxxxxxxxx"
  MailFrom.s = MailFrom
  Subject.s = "Test"
  MsgBody.s = "Testing PureSMTP"
  Attachments.s = ""
  Status.l = PureSMTP_SendMail(MailTo, MailFrom, Subject, MsgBody, Attachments)
  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
Did you try the awemail library available on the german forums ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by Progi1984 »

Christian Uceda wrote:Hi Gnozal

Sorry to pester you again, but PureSMTP doesn't work when I create a thread safe executable, it does compile and run but PureSMTP_OpenSMTPConnection() does nothing and always returns -2 :cry:

(When creating the executable I'm using: UserlibUnicodeThreadsafe)

I have tested this on two different computers, on both I used a network sniffer and it doesn't show any traffic at all when running the threadsafe executable.

When not building a threadsafe executable it works fine and I can even see the DNS resolution traffic, when on threadsafe executable even no DNS traffic can be seen.

Could you please have a look? :cry: :cry:
I just read this... and I have a question : do you check in options for compilation "Create unicode executable " & "Create threadsafe executable " options and adding "UserlibUnicodeThreadsafe" in "Library Subsystem" ?
Christian Uceda
User
User
Posts: 67
Joined: Thu Jul 29, 2010 10:53 am

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by Christian Uceda »

@gnozal

Hi,
I just downloaded this file and tried again in threadsafe+unicode mode : it works !
Tested with PB451RC2 and this file
Well I do not have 4.51RC2, I only have the 4.50 demo :(
Christian Uceda
User
User
Posts: 67
Joined: Thu Jul 29, 2010 10:53 am

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by Christian Uceda »

@Progi1984
I just read this... and I have a question : do you check in options for compilation "Create unicode executable " & "Create threadsafe executable " options and adding "UserlibUnicodeThreadsafe" in "Library Subsystem" ?
Yes, I added the UserlibUnicodeThreadsafe, however I'm not creating a Unicode executable, only threadsafe.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by gnozal »

Christian Uceda wrote:Well I do not have 4.51RC2, I only have the 4.50 demo :(
You have the demo ?
Sorry, but my libraries are designed for the full version. I have no experience with the PB demo.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by Progi1984 »

Christian Uceda wrote:@Progi1984
I just read this... and I have a question : do you check in options for compilation "Create unicode executable " & "Create threadsafe executable " options and adding "UserlibUnicodeThreadsafe" in "Library Subsystem" ?
Yes, I added the UserlibUnicodeThreadsafe, however I'm not creating a Unicode executable, only threadsafe.
Check it and try...
Christian Uceda
User
User
Posts: 67
Joined: Thu Jul 29, 2010 10:53 am

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by Christian Uceda »

@Progi1984

Yes, checking both threadsafe and unicode options make it work!

It's only when building the exe as threadsafe-only when it doesn't work.


Too bad I did not test this yesterday...

Because out of desperation I built my own SMTP code... :?

I did model it on the same work flow pure SMTP employs, so I did not have to modify my original code.
On the bright side, I know now how an SMTP server works from the inside out and I did learn properly how the SMTP headers work. And besides reworking all the code to support unicode would have been too painful, I like my strings ASCII ;)

From another angle I'm shattered because I worked under lots of pressure and did not sleep for many hours... :(

Anyway, many thanks to all.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by Progi1984 »

Just in threadsafe mode, use UserlibThreadsafe
Christian Uceda
User
User
Posts: 67
Joined: Thu Jul 29, 2010 10:53 am

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by Christian Uceda »

This is one of those a-ha! moments, so one uses

UserLibThreadsafe when using third party libraries with the threadsafe compiler option

and

UserLibThreadsafeUnicode when using third party libraries using the unicode and threadsafe executable flags on the compiler.

The funny part is that it is not funny :(

On the manual it says:
Library Subsystem
Here you can select a different PB subsystem for compilation. Currently the following subsystems are supported:

Windows
nt4 : uses DirectX3 only for any library that uses DirectX in order to be compatible to Windows NT 4.
opengl : uses OpenGL for the 3D libraries.

Linux
gtk1 : uses Gtk1.2 instead of Gtk2 for the compilation. (requires the gtk1.2-dev package)
Note that this subsystem is no longer maintained and some features may be missing.

MacOSX
There are currently no official subsystems for MacOSX.
No mention of UserLibThreadsafe or UserLibThreadsafeUnicode.

This story began because I got a polink error after switching the compiler to threadsafe on a program that used PureSMTP, I looked into the manual and it did not mention anything about polink errors, so I turned to the forum and search the error message.

I got a post in which someone told the person with the program to use the magic "UserLibThreadsafeUnicode" keyword on the compiler's library subsystem, so I did the same and the polink error dissapeared.

Two day's later I found out that PureSMTP could not send any message, and thought of some kind of bug... the rest is history.

End result 4 days of misery. :(

So why there is no mention of UserLibThreadsafe and UserLibThreadsafeUnicode in the documentation?

And not even a pull down option list with the magic keywords, at least having seen both I could have had a chance.

Aaargh! :x :x :x :x
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by gnozal »

Christian Uceda wrote:So why there is no mention of UserLibThreadsafe and UserLibThreadsafeUnicode in the documentation?
It is in the library documentation, not in the Purebasic documentation.
In PB's help file, you learn about subsystems, and the official ones : NT4, OpenGL, etc...
Now my libs use 3 subsystems, and these are not official subsystems, hence nothing about them in the official documentation.
However, there is a topic in PureSMTP.chm :
PureSMTP.chm -> Unicode_Thread-safe topic wrote:How to use this library in unicode and/or thread-safe mode

This library exists in several versions :
- the standard version, located in %Purebasic%\PureLibraries\UserLibraries\ ;
- the thread-safe version, located in %Purebasic%\SubSystems\UserLibThreadSafe\PureLibraries\ .
- the unicode version, located in %Purebasic%\SubSystems\UserLibUnicode\PureLibraries\ .
- the unicode + thread-safe version, located in %Purebasic%\SubSystems\UserLibunicodeThreadSafe\PureLibraries\ .
In order to use this library in thread-safe mode (compiler option /THREAD), you have to enable the subsystem 'UserLibThreadSafe'
in the PB IDE, or add '/SUBSYSTEM UserLibThreadSafe' to the PBCompiler arguments. In jaPBe, do nothing : it will automatically
enable the 'UserLibThreadSafe' subsystem to use the threadsafe versions of the installed userlibraries.
It's the same logic for unicode and unicode + thread-safe modes.
As you didn't spoke about POLINK errors, I didn't think you were using the wrong subsystem.
Christian Uceda wrote:And not even a pull down option list with the magic keywords, at least having seen both I could have had a chance.
There is one in jaPBe ;-)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Christian Uceda
User
User
Posts: 67
Joined: Thu Jul 29, 2010 10:53 am

Re: PureSMTP library : mail & attachments (AUTH supported)

Post by Christian Uceda »

Oh gosh :oops:

I completely thought it was some sort of internal compiler thing PB was providing in the sense that those keywords were coming from PB itself and not the third party libraries.

This is what happens when you code until very late hours... Start to see ghosts everywhere. :oops:

Sorry for crying wolf and wasting your time Gnozal. :cry:

Yes the polinks should have been a good start, but as I explained before, I did read on the forum about a similar problem, then found about the "UserLibThreadsafeUnicode" keyword. After putting it on the compiler the polink errors dissapeared, and from there it was wrong assumption after wrong assumption.

So much time lost... :(
loulou
User
User
Posts: 38
Joined: Tue Dec 08, 2009 7:42 am

PureSmtp questions deleting message sent with smtp

Post by loulou »

I want to delete a message sent by smtp outbox , is it possible with puresmtp ?
Thanks in advance
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PureSmtp questions deleting message sent with smtp

Post by IdeasVacuum »

... I think you may need gnozal's companion library, PurePOP3, which has the function PurePOP3_DeleteMessage(MessageNumber.l)


Description
Delete message at POP3 server.
Returns #PurePOP3_Ok if success (else is error code).

http://gnozal.ucoz.com/PurePOP3_.htm
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
loulou
User
User
Posts: 38
Joined: Tue Dec 08, 2009 7:42 am

Re: PureSmtp questions deleting message sent with smtp

Post by loulou »

I want to delete smtp mail in ougoing box not mail in inbox with pop3
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureSmtp questions deleting message sent with smtp

Post by gnozal »

loulou wrote:I want to delete a message sent by smtp outbox , is it possible with puresmtp ?
Thanks in advance
No, it isn't.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply