It is currently Thu May 28, 2020 3:45 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 337 posts ]  Go to page 1, 2, 3, 4, 5 ... 23  Next
Author Message
 Post subject: PurePOP3 library : POP3 functions
PostPosted: Sat Oct 01, 2005 12:02 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
PurePOP3 library V1 *BETA* (Last update : PB5.0x NOV 7th 2012)

Overview
Quote:
POP3 functions for Purebasic.

Features :

- count messages at POP3 server
- get message text
- get message attachments
- and more

Note : TLS/SSL is not supported


Functions
PB3.94 : http://gnozal.ucoz.com/PurePOP3.htm
PB4.xx : http://gnozal.ucoz.com/PurePOP3_.htm

Example
Code:
Server.s = "my.server.de"
Port.l = 110
User.s = "gnozal"
Pwd.s = "mypass"
;
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 "--------------"
      Debug "Message info : " + PurePOP3_GetMessageInfo()
      *Message = PurePOP3_GetMessageTextInMemory()
      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


Download
Only available for Purebasic Windows x86
PB3.94 : http://gnozal.ucoz.com/PurePOP3.zip
PB4.0x : http://gnozal.ucoz.com/PurePOP3_.zip
PB4.1x : http://gnozal.ucoz.com/PurePOP3__.zip
PB4.2x : http://gnozal.ucoz.com/PurePOP3___.zip
PB4.3x : http://gnozal.ucoz.com/PurePOP3_430.zip
PB4.4x : http://gnozal.ucoz.com/PurePOP3_440.zip
PB4.5x : http://gnozal.ucoz.com/PurePOP3_450.zip
PB4.6x : http://gnozal.ucoz.com/PurePOP3_460.zip
PB5.0x : http://gnozal.ucoz.com/PurePOP3_500.zip

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Last edited by gnozal on Tue Aug 18, 2009 11:53 am, edited 30 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Oct 01, 2005 12:07 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Lately, I had access to a POP3 server so I can post a beta version of my lib, as requested by some PureSMTP users.

I have tested it with one POP3 server and 3 mailers (including PureSMTP).
It has beta status because I could not test it with many POP3 servers.

In case of problem, you can activate the debug mode with PurePOP3_Trace(#TRUE) and send me the PurePOP3-DEBUG*.txt files (please delete personal information if applicable).
Thanks.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Oct 01, 2005 2:33 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Mar 02, 2004 1:20 pm
Posts: 1105
Location: Amphibios 9
Hallo gnozal,

thank's for your library. Well done! :D

There's a little bug in your Example-Code PurePop3_Test1.pb.

It's better to put your Message-Analyze into a for-next-loop.

Code:
If PurePOP3_OpenPOP3Connection(Server, Port, User, Pwd) = #PurePOP3_Ok
 
  Debug "Connected"
 
  ; PurePOP3_Trace(#TRUE)
 
  Messages = PurePOP3_CountMessages()
 
  Debug "You have " + Str(Messages) + " message(s)"
 
  If Messages
   
    Debug "Message(s) total size : " + Str(PurePOP3_GetMessagesTotalSize()) + " bytes"
   
    For MessageCounter = 1 To Messages
     
      Debug "Message " + Str(MessageCounter) + " size : " + Str(PurePOP3_GetMessageSize(MessageCounter)) + " bytes"
      Debug "Retrieve message " + Str(MessageCounter)
     
      If PurePOP3_RetrieveMessage(MessageCounter) > 0
        Debug "--------------"
        Debug "Message info : " + PurePOP3_GetMessageInfo()
        *Message = PurePOP3_GetMessageTextInMemory()
        If *Message
          Debug "Message text :"
          Debug "<start>"
          Debug PeekS(*Message)
          Debug "<end>"
        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
     
    Next ; MessageCounter
   
  EndIf
 
  PurePOP3_ClosePOP3Connection()
 
Else
 
  Debug PurePOP3_GetLastServerMessage()
 
EndIf


Greetings ... Kiffi


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Oct 01, 2005 3:08 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Kiffi wrote:
Hallo gnozal,
thank's for your library. Well done! :D
Thanks :D
Kiffi wrote:
There's a little bug in your Example-Code PurePop3_Test1.pb. It's better to put your Message-Analyze into a for-next-loop.
Greetings ... Kiffi
It's not really a bug, it's just an example (with the last message only [who knows how many messages one has ? :wink: ])...
There is a for-next-loop in the 2nd example file PurePop3_Test2.pb.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Oct 01, 2005 5:21 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Library update

Bug fix
PurePOP3_RetrieveMessage() fixed ; all POP3 servers don't reply the same way after RETR command.

Thanks for the feedback.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Oct 23, 2005 1:52 pm 
Offline
New User
New User

Joined: Sun Oct 23, 2005 1:43 pm
Posts: 8
Hi!

Nearly perfect Lib!

But one question:

Is there any posibility to store the complete message (text and attachment(s)) in one file?

CU


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 24, 2005 7:55 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Quote:
Nearly perfect Lib!
Thanks, it's still WIP.
Quote:
Is there any posibility to store the complete message (text and attachment(s)) in one file?
Actually, the only way is to activate the debug mode with PurePOP3_Trace(#true) and get the PurePOP3-DEBUG-RETR.txt file.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 24, 2005 2:54 pm 
Offline
New User
New User

Joined: Sun Oct 23, 2005 1:43 pm
Posts: 8
Hi!

For now I rewrite my code to handle your output...perhaps it is better. We will see ;)

A little function for saving the complete mail is a good feature for a new release of your lib.

CU


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 25, 2005 7:52 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Update

Changes
- Optional parameter FileName for function PurePOP3_RetrieveMessage()
If FileName is specified, the retrieved data is saved to the file (all the data : the header, the messages and all the attachements).

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Oct 29, 2005 2:50 pm 
Offline
New User
New User

Joined: Sun Oct 23, 2005 1:43 pm
Posts: 8
At first: Thanks for new parameter!!! :)

Pop3 seems to be a very "non-standard" protocol.

Month ago I tried to write my own pop3-retrival code but it did not work correctly.

It seems that so many diffrent formats are in use, that nobody can write a real good analyse routine to catch the mail from the mail-server.

Here is a little sample code from Eudora (sender) and my local mercury mail server:
Code:
Received: from spooler by loassis.de (Mercury/32 v4.01a); 29 Oct 2005 15:10:25 +0200
X-Envelope-To: <rom>
Return-path: <fl>
Received: from fl (192.168.132.60) by loassis.de (Mercury/32 v4.01a) with ESMTP ID MG00000A;
   29 Oct 2005 15:10:20 +0200
Message-Id: <6.1.2.0.0.20051029150955.021df2e8@pop3.loassis.de>
X-Sender: fl@192.168.132.60
X-Mailer: QUALCOMM Windows Eudora Version 6.1.2.0
Date: Sat, 29 Oct 2005 15:10:20 +0200
To: rom
From: Lars <fl>
Subject: Test
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed

134567890



This mail returns no Body-Text... With PurePOP3_GetMessageTextInMemory() but 134567890 should be correct.

In some cases the last two caracters are missing...

I do not have any suggestions for that pop3-behavior (I think this is not a library problem!!!). I bet: if you write the same mail with outlook or use another mail-server you get the correct result.

With the new (optional) parameter I can try to parse the mail with a separate routine. And the lib is now -the- replacement for getmail.exe.

Hope to see more releases!

If you need more example codes let me know.

Lars


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 31, 2005 9:54 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
tycoon wrote:
Pop3 seems to be a very "non-standard" protocol.
Yes, I noticed ...
So I had to build my [beta] library from examples I got from different mailers and pop3 servers. And it's worse when it comes to attachments.
I will continue to work on this library when I have some spare time.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 01, 2005 11:50 am 
Offline
New User
New User

Joined: Sun Oct 23, 2005 1:43 pm
Posts: 8
Quote:
So I had to build my [beta] library from examples I got from different mailers and pop3 servers.


...and ther are many mail-servers... :cry: and far more ways sending mails :x and much more things to check... :twisted:

It's a nice lib and I hope you find a way out of this jungle...

I will check the next release!

Lars


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 03, 2006 8:05 am 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1459
Location: North by Northwest
Hi Gnozal,
just testing this library of yours for the first time.
It's pretty easy to use 8)

One thing though:
While using "PurePOP3_GetMessageTextInMemory" I always get 3 chars less than it should be.

Don't know why, because the file PurePOP3-DEBUG-RETR.txt is complete.
PurePOP3_GetMessageSize reports 8 bytes less than the size of PurePOP3-DEBUG-RETR.txt.

Thanks in advance.
fsw


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 03, 2006 8:55 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
fsw wrote:
Hi Gnozal,
just testing this library of yours for the first time.
It's pretty easy to use 8)
Thanks.
Please remember it is still beta. POP3 seems to be a very "non-standard" protocol : each server answers differently, and attachements are a nightmare...

fsw wrote:
One thing though:
While using "PurePOP3_GetMessageTextInMemory" I always get 3 chars less than it should be.
Don't know why, because the file PurePOP3-DEBUG-RETR.txt is complete.
IIRC, PurePOP3_GetMessageTextInMemory() doesn't copy the last 3 characters '2E0D0A' wich are the 'End of message' marker.

fsw wrote:
PurePOP3_GetMessageSize reports 8 bytes less than the size of PurePOP3-DEBUG-RETR.txt.
PurePOP3_GetMessageSize() returns the value obtained with the POP3 'LIST' command.
IIRC, the PurePOP3-DEBUG-RETR.txt file is bigger because of the header (the first line like '+OK 19032 bytes').

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 03, 2006 9:11 am 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8113
Location: Fort Nelson, BC, Canada
I've played with it some and I must say it is two thumbs up. Very easy to use and gets the job done nicely.

One thing I noticed though, is that PurePOP3_GetMessageInfo() reports one attachment for a message that does not have any files attached. I'm guessing the message itself is counted as an attachment? Do we have to subtract 1 from that number to get the number of attached files? btw, thanks for the nice lib!

_________________
Veni, vidi, vici.


Last edited by netmaestro on Wed Feb 22, 2006 4:27 am, edited 3 times in total.

Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 337 posts ]  Go to page 1, 2, 3, 4, 5 ... 23  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye