PurePOP3 library : POP3 functions

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

Moderator: gnozal

rdority
User
User
Posts: 34
Joined: Mon Mar 30, 2009 10:46 pm
Location: Vancouver, BC

*Does a boolean need clearing in PurePOP3's server timeout??

Post by rdority »

Thanks PB, that looks similar to what I am trying to do.

I can only speak for myself but it has been my experience that when PurePop3_OpenPop3Connection() refuses to work it is when the Internet connection is disrupted after a successful connection.
  • 1) OpenPop3Connection() connects successfully.

    2) Internet connection becomes blocked; rj45 gets unplugged or software blocks the port.

    3) Some other PurePop3 function is called, either to get the # of messages, or retrieve a message and naturally it fails.

    4) 15 seconds later the PurePop3 experiences a server timeout.

    5) Internet connection gets re-established.
The mystery is that from this point forward, OpenPop3Connection() is no longer able to connect, even with a good Internet connection.

And it doesn't seem to help to call PurePop3_CloseConnection().

I suspect there is a boolean variable (called something like alreadyConnected) inside the PurePOP3 library that should (but doesn't) get cleared in the case of a server timeout.

This hypothetical boolean variable might be used to keep track of whether or not a connection has been established.

In this example, upon successfully connecting via PurePop3_OpenPop3Connection(...), the variable alreadyConnected is set to true.

Of course PurePop3_CloseConnection() would set the variable to false.

Picture this:

  • 1) PurePop3_OpenPop3Connection(...) successfully connects and sets the hypothetical boolean variable alreadyConnected to true, meaning "we're connected.. yeah baby, yeah."

    2) Internet connection is blocked or otherwise disrupted.

    3) Some other PurePop3 function is called and errors out.

    4) PurePop3 library experiences a server timeout after 15 seconds, but doesn't reset the boolean variable alreadyConnected to false!!!

    5) Internet connection is re-established.


Now, if this boolean variable exists and is now erroneously still true, perhaps it is preventing the PurePop3 library from connecting from now on!

The OpenConnection function might read something like this:

Code: Select all

Procedure PurePop3_OpenPop3Connection()
  If connected = #False
    ;attempt to connect
    [b]alreadyConnected[/b] = #True
  else
    ;don't connect, we're already connected
  endif
EndProcedure
[/b]

Even in a scenario like this, I would think that calling PurePOP3_CloseConnection() would reset the boolean variable.

Thus calling PurePOP3_CloseConnection() first and then calling PurePOP3_OpenPop3Connection() should work!

Still hypothetically speaking of course, it's as if because technically we're not still connected, and thus PurePOP3_CloseConnection() isn't able to fully complete it's desired course of action, the boolean variable alreadyConnected never ends up getting cleared / reset to false.

This would certainly explain why no sequence of calls to PurePOP3_CloseConnection and PurePOP3_OpenPop3Connection() seems to make a difference.

It would also explain why closing the app and reopening it would fix the problem.

In this case, the boolean variable alreadyConnected would finally be initialized to false, thus making it possible to connect once again!
  • This is why I was thinking there might be a PurePOP3 function to re-initialize all library variables that would be helpful to know about. ;)

    Or if there's a way to ask PureBasic to restart a specific library.

    Or a way to fake PureBasic into "thinking" the app was just launched, ie a way to initialize all variables, essentially restarting the app from the beginning, but not having to launch another instance of the app before shutting down the current instance, etc.
I'm surprised no one else seems to have experienced this or mentioned it on this forum considering that PurePOP3 has been in development since back in 2005!?

Perhaps something (dare I say a 'bug') has crept into the library? :p

A friend of mine recently said, "it sure seems that a development environment these days should come with a fully functional suite of POP3 and SMTP functions."

Sad to say, this could reflect poorly on Pure Basic in general.

Roark[/b]
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: *Does a boolean need clearing in PurePOP3's server timeo

Post by PB »

> my experience that when PurePop3_OpenPop3Connection() refuses to
> work it is when the Internet connection is disrupted after a successful
> connection

+1, my internet connection is dodgy and disconnects at random. Once it
gets re-established, PurePOP3 can't do a thing with it, until I re-launch my
app. I definitely feel that PurePOP3 is holding on to the previous connection
and its setup, and hasn't recognized that a new connection has taken place.
That would explain why a re-launch of our apps solves the problem for us.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
rdority
User
User
Posts: 34
Joined: Mon Mar 30, 2009 10:46 pm
Location: Vancouver, BC

Is there an alternative library to PurePOP3??

Post by rdority »

Hey PB,

Do you recall hearing anything about bpePOP3?

I was going to use it in the beginning and for some reason switched over to PurePOP3.

Now I'm thinking I may go back to using bpePOP3.

I started to replace some of the function calls to use bpePOP3 instead. So far I am getting a strange complier error which reads as follows:

"A PureLibrary is missing: MEMORYEXTENSION."

Have you tried using bpePOP3?

Thanks,
Roark
rdority
User
User
Posts: 34
Joined: Mon Mar 30, 2009 10:46 pm
Location: Vancouver, BC

Looking for an alternative to PurePop3 library!!!

Post by rdority »

Hey all,

Does anyone have an alternative to the PurePOP3 library??

I am finding that it never recovers when the Internet connection is blocked or otherwise disconnected while email is being retrieved.

The only recourse so far that I've found is to literally close the app and reopen it. This is not a viable solution as it does not provide that "professional feel" in a software application.

There is only one other POP3 library that I'm aware of called bpePOP3 and it is apparently no longer being supported by its author, Brendan. I have tried it and get a bogus message which reads something like "A PureLibrary is missing: MEMORYEXTENSION" which is of no help.

So I'm hoping there is a 3rd POP3 library since sometimes the "3rd time is the charm."

Thanks,
Roark

p.s. It's a little embarrassing to admit to my friend that so far PureBasic does not seem to have a reliable POP3 library available to its developers. It is one thing for PureBasic to not include a reliable Pop3 library of its own. But for there to be none available. That's a shame.
User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

Post by graves »

see at www.blat.net

you may use blat.dll (embedded on your application), or blat.exe (external), as your convenience
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Blat is for sending mail, not receiving it.

I haven't used bpePOP3 but that error message means it was written for an
earlier version of PureBasic, and if the author isn't supporting it, then you're
out of luck.

The app I'm writing has no window; it's basically a POP3 monitor, so quitting
it and restarting it, when PurePOP3 fails, is of no real concern to me. I can
live with it until Gnozal can fix the problem.

As for being embarrassed about PureBasic not natively supporting POP3, it's
really no big deal, is it? Who cares? It'll come soon enough. PureBasic is still
better than a lot of other Basics out there.

But to answer your question, maybe take a look at this:

http://www.ostrosoft.com/pop3_component.asp

Quote: "OSPOP3.dll is a COM library for retrieving email messages from
POP3 mailserver, checking mailbox status, parsing retrieved messages
from Visual Basic 6 and other programming and scripting languages,
supporting COM."

Price: Free unlimited usage for developing non-commercial applications.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Hurga
Enthusiast
Enthusiast
Posts: 148
Joined: Thu Jul 17, 2003 2:53 pm
Contact:

Post by Hurga »

PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Is there an alternative library to PurePOP3??

Post by PB »

> Have you tried using bpePOP3?

No. (See my other post in this forum topic, where I replied to you).

Can somebody else confirm this problem? Maybe by setting up a loop to
check your POP3 inbox, then disconnect your network cable while the app
is still running, then reconnect the network and see if your app can still
parse the inbox? Thanks!
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Looking for an alternative to PurePop3 library!!!

Post by gnozal »

rdority wrote:Hey all,

Does anyone have an alternative to the PurePOP3 library??

I am finding that it never recovers when the Internet connection is blocked or otherwise disconnected while email is being retrieved.

The only recourse so far that I've found is to literally close the app and reopen it. This is not a viable solution as it does not provide that "professional feel" in a software application.
Hi,
PurePOP3 uses the purebasic network library.
PurePOP3_OpenPOP3Connection() works like this :
- InitNetwork() if it's not already done by the lib [you can disable this with PurePOP3_SkipInitNetwork()]
- OpenNetworkConnection(POP3server, POP3Port)
- wait for server answer, if "+OK" send user / password.
I don't know how to resume a lost connection with PB network commands.
Did you try PurePOP3_Reset() to 'reset' the server ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Is there an alternative library to PurePOP3??

Post by gnozal »

rdority wrote:I started to replace some of the function calls to use bpePOP3 instead. So far I am getting a strange complier error which reads as follows:
"A PureLibrary is missing: MEMORYEXTENSION."
It seems like this library does not support PB4.30. You could try to compile it as a DLL using a compatible PB version, and then use this DLL with PB 4.30.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Looking for an alternative to PurePop3 library!!!

Post by PB »

Hmm, I haven't been using PurePOP3_SkipInitNetwork() with my app, and my
app also calls InitNetwork(). So maybe that's where the problem is coming
from. I'll let you know tomorrow after some testing. I assume that #True
is the flag for PurePOP3_SkipInitNetwork()? The help doc doesn't say what
values it expects.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Looking for an alternative to PurePop3 library!!!

Post by gnozal »

PB wrote:I assume that #True is the flag for PurePOP3_SkipInitNetwork()?
Yes
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
UserOfPure
Enthusiast
Enthusiast
Posts: 469
Joined: Sun Mar 16, 2008 9:18 am

PurePOP3 for 4.40?

Post by UserOfPure »

Hi gnozal, does this work with 4.40 properly? One of my apps has "b=PurePOP3_GetMessageTextInMemory()" but b=0 when I use it, even though the mail has been read correctly with PurePOP3_RetrieveMessage(#) before it.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PurePOP3 for 4.40?

Post by gnozal »

UserOfPure wrote:Hi gnozal, does this work with 4.40 properly? One of my apps has "b=PurePOP3_GetMessageTextInMemory()" but b=0 when I use it, even though the mail has been read correctly with PurePOP3_RetrieveMessage(#) before it.
It should. Did it work with PB4.3x for the same message ?

- Maybe the text is only available as HTML (try PurePOP3_IsMessageHTML()), so you have to use PurePOP3_GetMessageTextInMemory(#True).
or
- Maybe you found a bug ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
UserOfPure
Enthusiast
Enthusiast
Posts: 469
Joined: Sun Mar 16, 2008 9:18 am

Re: PurePOP3 for 4.40?

Post by UserOfPure »

Hi, yes, it works now with b=PurePOP3_GetMessageTextInMemory(#True) instead. But that's weird, because I've been sending the same types of mail over and over so far, and this is the first time I've had to use the #True flag with it.

Anyway, is there any harm in using b=PurePOP3_GetMessageTextInMemory(#True) all the time, even if the mail is NOT html? Or should I always check first with PurePOP3_IsMessageHTML() and then do an If/Then accordingly?
Post Reply