PurePOP3 library : POP3 functions

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

Moderator: gnozal

C64
Enthusiast
Enthusiast
Posts: 151
Joined: Sat Dec 18, 2010 4:40 am

Re: PurePOP3_IsMessageHTML() hangs

Post by C64 »

gnozal wrote:Without the traces, I can do zip.
See your PM. ;) Thanks.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: PurePOP3 library : POP3 functions

Post by PB »

Interesting. My app was also having issues and it uses this command, so I will be watching this fix with interest, in case it's the problem I've been having.
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: PurePOP3 library : POP3 functions

Post by gnozal »

I have updated the library (PB 4.50 version).

The problem was that the boundary definition in your mail was missing quotes. I have updated the library internal functions to handle this case. Hopefully, it will not break anything else.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
C64
Enthusiast
Enthusiast
Posts: 151
Joined: Sat Dec 18, 2010 4:40 am

Re: PurePOP3 library : POP3 functions

Post by C64 »

gnozal wrote:I have updated the library (PB 4.50 version).
Thank you gnozal, I can confirm it works correctly now. :)
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

PurePOP3_OpenPOP3Connection() with invalid params

Post by MachineCode »

I just noticed today that if I call PurePOP3_OpenPOP3Connection() with an invalid username or invalid password, then my app freezes at that command and uses 50% CPU while the command tries to authenticate during its timeout period. So, is it possible this command can be modified to not use such high CPU during authentication? Because my PC slowed down noticeably today and I didn't realise why at first, and then discovered it was due to my app trying to authenticate with an invalid username.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PurePOP3_OpenPOP3Connection() with invalid params

Post by gnozal »

MachineCode wrote:I just noticed today that if I call PurePOP3_OpenPOP3Connection() with an invalid username or invalid password, then my app freezes at that command and uses 50% CPU while the command tries to authenticate during its timeout period. So, is it possible this command can be modified to not use such high CPU during authentication? Because my PC slowed down noticeably today and I didn't realise why at first, and then discovered it was due to my app trying to authenticate with an invalid username.
- PurePOP3 uses Delay() in the loop waiting for the POP server answer.
- you could try to change the time out using PurePOP3_SetTimeOut()

Anyway, I have updated the PurePOP3 library with a slightly greater delay. Maybe it helps.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePOP3_OpenPOP3Connection() with invalid params

Post by MachineCode »

gnozal wrote:I have updated the PurePOP3 library with a slightly greater delay. Maybe it helps.
Yep, my app now shows 0% CPU in the Task Manager when trying to connect with an invalid login, instead of 50%. Thank you!
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
SunSatION
User
User
Posts: 85
Joined: Tue Jun 21, 2005 7:26 pm
Location: Malta

Re: PurePOP3 library : POP3 functions

Post by SunSatION »

Hi gnozal.

I'm wondering whether it is possible or not to implement the TOP function provided by POP? The reason behind this is that I would like to get just the header part ( subject, address, .... ) without actually downloading the whole message before.

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

Re: PurePOP3 library : POP3 functions

Post by gnozal »

Update (PB4.5x version)

Changes :
- New function PurePOP3_RetrieveInfo(MessageNumber.l) [see help file]
  Retrieve message headers from POP3 server.
  . This function only retrieves the headers (not the message, nor the attachments) : use only PurePOP3_GetMessageInfo() after it.
  . Not all mail servers support the POP3 TOP command but if they do it is useful for only retrieving part of the message.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
SunSatION
User
User
Posts: 85
Joined: Tue Jun 21, 2005 7:26 pm
Location: Malta

Re: PurePOP3 library : POP3 functions

Post by SunSatION »

Thanks again gnozal. Works like a charm
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePOP3 library : POP3 functions

Post by MachineCode »

Found an issue with the way PurePOP3 parses a HTML email. Here's a snippet of the email's raw source:

Code: Select all

--=_alternative 0007629ECA25785F_=
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset="ISO-8859-1"

<FONT face=3D"Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size=
=3D2><P style=3D"MARGIN: 0px">Thank you!!!</P><P style=3D"MARGIN: 0px">webu=
rl <A href=3D"http://www.bluesnews.com" target=3Dblank>http://www.bluesnews=
.com</A>--</P><P style=3D"MARGIN: 0px">&nbsp;</P></FONT><font face=3D"sans-=
serif"><p style=3D"font-weight:bold; font-family:sans-serif; font-size:12px=
The PurePOP3_IsMessageHTML() command returns 1 for the above. But then when I use PurePOP3_GetMessageTextInMemory(1) with it, the URL of "www.bluesnews.com" is returned in the body as "www.bluesnews..com" by mistake. Note the double-periods. I assume this is because in the raw source above, there is a "=" before the ".com" in the email, and the URL is also broken over two lines at that exact part of text. Hope this can be fixed easily.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PurePOP3 library : POP3 functions

Post by gnozal »

MachineCode wrote:Found an issue with the way PurePOP3 parses a HTML email.

Code: Select all

<FONT face=3D"Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size=
=3D2><P style=3D"MARGIN: 0px">Thank you!!!</P><P style=3D"MARGIN: 0px">webu=
rl <A href=3D"http://www.bluesnews.com" target=3Dblank>http://www.bluesnews=
.com</A>--</P><P style=3D"MARGIN: 0px">&nbsp;</P></FONT><font face=3D"sans-=
serif"><p style=3D"font-weight:bold; font-family:sans-serif; font-size:12px=
I use a decode routine which should handle the '=' stuff.
Basically, it does this :
  =CRLF => nothing
  ..CRLF => .CRLF
  =XX => CHR(DEC(XX)) < if XX is a valid HEX number >
Using your snippet above and assuming that there is a CRLF after each line, my decode routine outputs this :

Code: Select all

<FONT face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size=2><P style="MARGIN: 0px">Thank you!!!</P><P style="MARGIN: 0px">weburl <A href="http://www.bluesnews.com" target=blank>http://www.bluesnews.com</A>--</P><P style="MARGIN: 0px">&nbsp;</P></FONT><font face="sans-serif"><p style="font-weight:bold; font-family:sans-serif; font-size:12px=
Which looks fine to me.
I can't test more without the complete traces.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePOP3 library : POP3 functions

Post by MachineCode »

I did some checking. The source I posted above is what my ISP shows as the raw message source. But when I used PurePOP3_Trace(1), the debug files actually show it like this:

Code: Select all

--=_alternative 0007629ECA25785F_=
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset="ISO-8859-1"

<FONT face=3D"Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size=
=3D2><P style=3D"MARGIN: 0px">Thank you!!!</P><P style=3D"MARGIN: 0px">webu=
rl <A href=3D"http://www.bluesnews.com" target=3Dblank>http://www.bluesnews=
..com</A>--</P><P style=3D"MARGIN: 0px">&nbsp;</P></FONT><font face=3D"sans-=
serif"><p style=3D"font-weight:bold; font-family:sans-serif; font-size:12px=
So, it seems your library is adding a second dot for some reason? Is there any point me sending you the traces if they don't match the raw source in the first place? If so, I will do it. Let me know.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PurePOP3 library : POP3 functions

Post by gnozal »

Now that's odd : the dumps are the exact copy of the data received with ReceiveNetworkData().

Code: Select all

...
BytesRead = ReceiveNetworkData(PurePOP3_ConnectionID, PurePOP3_Buffer, #PurePOP3_Buffer_Len)
...
; //////// DEBUG ////////
LIB_Debug("- RECEIVED (Buffer) : " + Str(BytesRead) + " BYTES")
LIB_Debug("<dump>")
LIB_Debug(PeekS(PurePOP3_Buffer, BytesRead))
LIB_Debug("</dump>")
; //////// DEBUG ////////
...
PurePOP3-DEBUG-COM.txt shows all the communication, PurePOP3-DEBUG-RETR-XX.txt only the final complete message.

Do you also find the duplicated dot in PurePOP3-DEBUG-COM.txt ? If yes, that's what ReceiveNetworkData() gets...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePOP3 library : POP3 functions

Post by MachineCode »

Yes, both "PurePOP3-DEBUG-COM.txt" and "PurePOP3-DEBUG-RETR-000.txt" have the double dot, but the message source in my ISP's webmail has only one. It's like the message source you get in Gmail when you click "Show original" when viewing an email. As a side-note, the "text/plain" part of these emails are correct, with only one dot ("weburl http://www.bluesnews.com--").

Maybe my ISP is fixing the double-dot when showing me the source? This might be a false alarm...?
Last edited by MachineCode on Sat Mar 26, 2011 12:29 pm, edited 1 time in total.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Post Reply