PurePOP3 library : POP3 functions

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: PurePOP3 library : POP3 functions

Post by gnozal »

That's the first time someone posts an issue like this one.

I am sorry, but if ReceiveNetworkData() gets a double dot, I don't see what I can do ...

Any antivirus software between your ISP and PurePOP3 ?
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 just edited my last post while you replied. I'm thinking my ISP isn't showing the true source? What I'll do, is wait till Monday and send another email the same, but I'll view the source of the sent mail instead, to see what was actually sent, rather than what was received.

Edit: I just got a second opinion using www.mail2web.com and it also shows the message source with only one dot, so it's weird. Be interesting to see on Monday what is being sent.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePOP3 library : POP3 functions

Post by MachineCode »

As promised, here's the source of the sent email (well, the <script> part that matters anyway). This source was obtained by right-clicking the Lotus Domino sent email, and selecting "View source" from the popup menu. No sign of a double-dot anywhere, so I don't have any idea where it's coming from. Very strange! Just ignore my bug report for now as I don't think it'll be a major issue.

Code: Select all

<script>
var BodyHtml='<FONT face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size=2><P style="MARGIN: 0px">Thank you!!!\n</P><P style="MARGIN: 0px">weburl \n<A href="http://www.bluesnews.com" target=blank>http://www.bluesnews.com\n</A>--\n</P><P style="MARGIN: 0px">&nbsp;\n</P></FONT>\n';
var StatusUpdateHtml='',SendToHtml='Me_At_Home',CopyToHtml='',BlindCopyToHtml='',FromHtml='Me_At_Work',SubjectHtml='Testing url';
var PrincipalHtml='Me_At_Work',HeaderHtml='',FooterHtml='',FollowUpTextHtml='';

var aT='0';
var CWu =false;
var DOx=false;
var CXR=haiku.bFollowUpView;
</script>
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 »

Very strange indeed !
I don't have any idea either ...
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 »

Could functions be added to PurePOP3 that gets the subject, from, and other such fields? Currently, we have to use the PurePOP3_RetrieveMessage() function and then parse it manually. I can do that, but I discovered today that some email addresses are sent in different formats, like: "name@domain.com" and "Display Name <name@domain.com>". I only want to get the real actual email address, so I have strip off the display name and remove the < and > to get the real address. So a function to get it would be nice... like PurePOP3_GetSenderAddress() and PurePOP3_GetSubject(), and so on. But only if you have time and agree that it's a good idea. ;)
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:Could functions be added to PurePOP3 that gets the subject, from, and other such fields? Currently, we have to use the PurePOP3_RetrieveMessage() function and then parse it manually. I can do that, but I discovered today that some email addresses are sent in different formats, like: "name@domain.com" and "Display Name <name@domain.com>". I only want to get the real actual email address, so I have strip off the display name and remove the < and > to get the real address. So a function to get it would be nice... like PurePOP3_GetSenderAddress() and PurePOP3_GetSubject(), and so on. But only if you have time and agree that it's a good idea. ;)
There is PurePOP3_GetMessageInfo()
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 »

Typo in my last post. I meant to say PurePOP3_GetMessageInfo(), not PurePOP3_RetrieveMessage(). Parsing it is what I want to avoid, for the reasons I gave. It's a tad inconvenient to strip the actual email address out. Maybe there's an easy way with regular expressions, but I have no idea how to use them.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePOP3 library : POP3 functions

Post by MachineCode »

Another question: I've just been made aware that I shouldn't be checking for English words in my app, because it means my app will fail on non-English PCs. The help for the PurePOP3_GetMessageInfo() command says that it returns a string like "Delivery-date:xxx<9>Subject:xxx<9>". My question is: on a non-English PC, will the text "Subject" in that returned string always be "Subject" on any language PC, or will it be "sous réserve" on French PCs, or "Thema" on German PCs?
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:Another question: I've just been made aware that I shouldn't be checking for English words in my app, because it means my app will fail on non-English PCs. The help for the PurePOP3_GetMessageInfo() command says that it returns a string like "Delivery-date:xxx<9>Subject:xxx<9>". My question is: on a non-English PC, will the text "Subject" in that returned string always be "Subject" on any language PC, or will it be "sous réserve" on French PCs, or "Thema" on German PCs?
It should be in english on any PC.
AFAIK, "Delivery-date:" etc.. are common Internet message headers.
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 »

Found a bug... I sent myself an email of a note to remind myself of something, but the body gets cropped due to an equals sign. Here's the body of what I sent:

Code: Select all

play c:\timescapes.mp4 /from=003
But PurePOP3 crops everything after the "from" word, ie. "=003" is gone. I was using this to retreive the body:

Code: Select all

html=PurePOP3_IsMessageHTML()
b=PurePOP3_GetMessageTextInMemory(html)
If b : body$=PeekS(b) : EndIf
If I replace "from=003" with "from-003" in my sent email, then it all works fine.
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 a bug... I sent myself an email of a note to remind myself of something, but the body gets cropped due to an equals sign.
I found out that some email clients encode the message using the '=' sign to encode some special characters.
So 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 >
I don't know how to decode it otherwise.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
ruslanx
User
User
Posts: 46
Joined: Mon Jun 06, 2011 8:28 am

Re: PurePOP3 library : POP3 functions

Post by ruslanx »

I can't get mail body (message),I receive only this ... ?

This is a multi-part message in MIME format.

code:
.....
*Message = PurePOP3_GetMessageTextInMemory()
If *Message
Debug PeekS(*Message)
PurePOP3_FreeMessagePointer(*Message)
EndIf
.....

why,what is wrong ???

.. was sent with blat ..
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 »

ruslanx wrote:I can't get mail body (message),I receive only this ... ?
This is a multi-part message in MIME format.
why,what is wrong ???
.. was sent with blat ..
Probably some issue with the message structure.
Library bug or BLAT issue ?
Maybe PurePOP3_GetMessageTextInMemory(1) works (only HTML text) ?
I can only guess without the traces (see help : PurePOP3_Trace()).
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 just noticed today that http://www.mailinator.com now supports POP3.

Background: Mailinator is an email service where you can create throwaway email addresses for whatever reason, such as "purepop3_is_cool@mailinator.com". If you then send an email to that address, you can view it by logging in http://www.mailinator.com and entering "purepop3_is_cool" as the login name. It's great for preventing spam when you need to give someone a temp email address, instead of your real email address.

Now, they've added POP3 support, so instead of logging into their website, you can view the "purepop3_is_cool" inbox by using POP3 commands. But when I tested it with PurePOP3, it's not working. Specifically, it says the inbox has 2 messages when only 1 exists, and it doesn't return the body of the message. See below for steps to reproduce.

(1) Send an email to "purepop3_is_cool@mailinator.com" (or another address, in case people in these forums are testing it too; we don't want it to clash with lots of emails, as we only want ONE SINGLE EMAIL to be in the Mailinator inbox). Leave the email subject blank, and for the body, put only this (including the double brackets): [[this is a test]]

(2) Run the following code. It says 2 mails exist (instead of 1), and it can't retrieve the body.

Code: Select all

Server.s = "pop.mailinator.com"
Port.l = 110
User.s = "purepop3_is_cool"
Pwd.s = "can_be_anything"

If PurePOP3_OpenPOP3Connection(Server, Port, User, Pwd) = #PurePOP3_Ok
   Debug "Connected"
   PurePOP3_Trace(#True)
   Messages = PurePOP3_CountMessages()
   Debug "You have " + Str(Messages) + " messages(s)"
   If Messages
      Debug "Message(s) total size : " + Str(PurePOP3_GetMessagesTotalSize()) + " bytes"
      Debug "Message " + Str(Messages) + " size : " + Str(PurePOP3_GetMessageSize(Messages)) + " bytes"
      Debug "Retrieve message " + Str(Messages)
      If PurePOP3_RetrieveMessage(Messages) < 0
        Debug "Message NOT retrieved"
      Else
         Debug "--------------"
         Debug "Message info : " + PurePOP3_GetMessageInfo()
         *Message = PurePOP3_GetMessageTextInMemory()
         CallDebugger
         If *Message
            Debug "Message text :"
            Debug ""
            Debug PeekS(*Message)
            Debug ""
            PurePOP3_FreeMessagePointer(*Message)
         EndIf
         Attachements.s = PurePOP3_ListAttachementsForMessage()
         If Attachements
            Debug "----------------"
            Debug "Attachement(s) : " + Attachements
            If PurePOP3_SaveAttachementsToFile("")
               Debug "Attachement(s) saved to current directory"
            Else
               Debug "Could not save attachement(s)"
            EndIf
         Else
            Debug "--------------"
            Debug "No attachments"
         EndIf
      EndIf
   EndIf
   PurePOP3_ClosePOP3Connection()
Else
   Debug PurePOP3_GetLastServerMessage()
EndIf

Debug "PurePOP3 finished"
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:I just noticed today that http://www.mailinator.com now supports POP3.
I sent a message to purepop3_is_cool@mailinator.com (email subject blank, and '[[this is a test]]' as body).
I tried your code :

Code: Select all

SEND : STAT

RECEIVE : +OK 1 790 <------------- OK

SEND : LIST 1

RECEIVE : +OK 1 790 <--------------- OK

SEND : RETR 1

- RECEIVED (Buffer) : 3 BYTES <-------------- PROBLEM
<dump>
.

</dump>
- RECEIVED (Buffer) : 1326 BYTES <--------- THIS SHOULD BE THE ANSWER !
<dump>
+OK 1309 octets
Received: by dadz9 with SMTP id z9so2657273dad.8
        for <purepop3_is_cool@mailinator.com>; Mon, 30 Jan 2012 00:46:51 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=mime-version:date:message-id:subject:from:to:content-type;
        bh=D97fxyLk045DhkQLZ1JHzEHLUtSIes21jrOSPrB+I8Y=;
        b=iGbxX9vvnr6xBm9MaCrFWfGsetCG6Nxl+iTiwqzu8qYHOJq1fD5oQyAdhlcdW1WloN
         s/fBKG22BD+g5bB6pZNViDH3w7uJuDND2HhWDGqh0ye3JEonCoyNoGJOsDcS5dsfU/Zu
         pMMfqVTQAp4vOaMZVMa3RBEWfYAhOsbSNZG8c=
MIME-Version: 1.0
Received: by 10.68.200.65 with SMTP id jq1mr40659211pbc.54.1327913210990; Mon,
 30 Jan 2012 00:46:50 -0800 (PST)
Received: by 10.68.28.136 with HTTP; Mon, 30 Jan 2012 00:46:50 -0800 (PST)
Date: Mon, 30 Jan 2012 09:46:50 +0100
Message-ID: <CAHd0PhnRY-Tg6pPRz7wyN3sq8iLv-VvMqcTnwTrUy3U3qsGP1w@mail.gmail.com>
Subject: [MAILINATOR] 
From: Atlan Gnozal <XXX@GMAIL.COM>
To: purepop3_is_cool@mailinator.com
Content-Type: multipart/alternative; boundary=047d7b10d1193bd13704b7bae3c7

--047d7b10d1193bd13704b7bae3c7
Content-Type: text/plain; charset=ISO-8859-1

[[this is a test]]

--047d7b10d1193bd13704b7bae3c7
Content-Type: text/html; charset=ISO-8859-1

[[this is a test]]<br>

--047d7b10d1193bd13704b7bae3c7--
.

</dump>
* END OF COM [CRLF . CRLF]
* RECEIVED (TOTAL) : 1329 BYTES
* DUMP n°0 in file <PurePOP3-DEBUG-RETR-000.txt>
SEND : QUIT

RECEIVE : +OK bye see you soon
And you can see the issue.
After the RETR 1 command, the server answers with 3 bytes '. ' ??
PurePOP3 aborts if it doesn't get '+OK' as expected.
Seems to be a server issue.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply