It is currently Sat May 25, 2013 8:16 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 336 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 23  Next
Author Message
 Post subject:
PostPosted: Thu Jan 11, 2007 4:58 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 2853
Location: United Kingdom
Very *very* nice lib :)

Is there anyway you could add a function to grab the complete header text (rather than having to examine the memory buffer).

eg:
Code:

PurePOP3_GetMessageHeader()

Get header from retrieved message.

Must be used after PurePOP3_RetrieveMessage().

Returned values :
- String like 'Return-Path: <xxx@xxx.com><9>X-Original-To: xx@xxx.com<9>Delivered-To: xxx@xxx-xxx.xxx.com<9>Organization: xxx<9>Content-Type: text/plain; charset=us-ascii'
  where <9> is TAB (ASCII code 9)
- Empty string : error


Example

If PurePOP3_RetrieveMessage(MessageNumber.l) > 0
      Debug "Header info : " + PurePOP3_GetMessageHeader()
EndIf


Being able to parse the header easily would be great for checking against spam lists, etc

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 8:33 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
DoubleDutch wrote:
Very *very* nice lib :)

Is there anyway you could add a function to grab the complete header text (rather than having to examine the memory buffer).

I will try to remember this for the next version :wink:

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 1:03 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 2853
Location: United Kingdom
Thats great, thanks - having header data would have endless uses. :)

I had some really strange problems with the libs using the threaded versions.
It seemed to be something to do with the SMTP library and then sometimes the pop3 library refusing to get a connection until you reran the program.

I think however I was wrong and that it may actually be nothing to do with your libs, but actually something to do with PureBasic itself and some kind of issue with linked lists being accessed (even if you mutex and reload the index) with different threads. Someone (in the know) needs to do a write-up on exactly how strings work in a multithreaded purebasic program - and what exactly are the rules... Fred?

Anyhow - I think I've fixed the problem by using a database to store the data in - rather than linked lists. The major benefit is that all email 'transactions' are now 'backup up' in a an mdb. :)

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 7:55 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 2853
Location: United Kingdom
If you include the top procedure (even if its not called) it will crash the main routine with an invalid memory error after a couple of passes.

Code:
Procedure SmtpErrorText(code)
   error$=""
   Select code
      Case   #PureSMTP_FileError
         error$="SMTP error => File error"
      Case   #PureSMTP_NoConnection
         error$="SMTP error => No connection"
      Case   #PureSMTP_BadResponse
         error$="SMTP error => Bad response ("+PureSMTP_GetLastServerMessage()+")"
      Case   #PureSMTP_MemoryAllocationProblem
         error$="SMTP error => Memory allocation problem"
      Case   #PureSMTP_AuthentificationFailed
         error$="SMTP error => Authentication failed"
      Case   #PureSMTP_ServerTimeOut
         error$="SMTP error => Server timeout"
      Default
         error$="SMTP error => Unknown error code:"+Str(code)
   EndSelect
EndProcedure

For loop=1 To 100
Server.s = "mail.domain.com"
Port.l = 110
User.s = "user@domain.com"
Pwd.s = "pass"
;
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 "<start>"
        Debug PeekS(*Message)
        Debug "<end>"
        FreeMemory(*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
Next


Very strange?

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 8:04 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 2853
Location: United Kingdom
It looks like if you include any command from puresmtp and purepop3 within the same program, they mess each other up - if you use more than one pass.

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 13, 2007 10:20 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
DoubleDutch wrote:
If you include the top procedure (even if its not called) it will crash the main routine with an invalid memory error after a couple of passes.
Very strange?
Very !
Can't reproduce it though.
DoubleDutch wrote:
It looks like if you include any command from puresmtp and purepop3 within the same program, they mess each other up - if you use more than one pass.
Do you have some code ?

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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 13, 2007 11:58 am 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 2853
Location: United Kingdom
After a reboot - the problem has gone away!

Weird...

Thanks anyhow.

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 10:56 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 2853
Location: United Kingdom
I've done some tests with attachments and PureSmtp and PurePop3 both seem to append extra an extra $0D0A to the end of the file (each adds 2 bytes).

The file was a text file consisting of 'blah blah blah!' (15 bytes, no CR)
PureSMTP made it 17 bytes long (verified with TheBat and Outlook) and PurePop3 made it 19 bytes long (verified with a direct PurePOP3_SaveAttachementsToFile command)

Also, during the course of the 'testing', I think I may have found an attachment type that is not compatible (from TheBat), here is a dump of the raw message:

<Dump><n°0>
+OK 1213 octets follow.
Return-Path: <user@domain.com>
X-Original-To: user@domain.com
Delivered-To: user@domain.com
Received: from [192.168.0.11] (xxxx.dsl.xx.co.uk [xxx])
by spunkyxxxxxxxxamhost.com (Postfix) with ESMTP id 37444433371DC
for <user@domain.com>; Tue, 16 Jan 2007 13:44:49 -0800 (PST)
Date: Tue, 16 Jan 2007 21:44:56 +0000
From: User Test at ezxretary <user@domain.com>
X-Mailer: The Bat! (v3.95.6) Professional
X-Priority: 3 (Normal)
Message-ID: <30102445813.200745346214456@exxxxy.com>
To: user@domain.com
Subject: test
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----------2016923D21EACDB9"

------------2016923D21EACDB9
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello ,



--
Best regards,
User mailto:user@domain.com
------------2016923D21EACDB9
Content-Type: text/plain;
name="this is a test.txt"
Content-transfer-encoding: base64
Content-Disposition: attachment;
filename="this is a test.txt"

YmxhaCBibGFoIGJsYWgh
------------2016923D21EACDB9--

.
</Dump>


I've changed any identifying marks to stop my email from being spammed! ;)

When PurePop3 saves the attachment, it ends up as:

YmxhaCBibGFoIGJsYWgh

It should be:

blah blah blah!

Maybe its the extra two '--' that TheBat puts at the end of an attachment boundary string?

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 8:45 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
DoubleDutch wrote:
I've done some tests with attachments and PureSmtp and PurePop3 both seem to append extra an extra $0D0A to the end of the file (each adds 2 bytes).
I know :wink:
Only for plain text.
Maybe I will fix it.
DoubleDutch wrote:
Also, during the course of the 'testing', I think I may have found an attachment type that is not compatible (from TheBat)
It's because TheBat writes 'Content-transfer-encoding', and PurePOP3 is looking for 'Content-Transfer-Encoding:' (but TheBat writes 'Content-Disposition:' and not 'Content-disposition:') ...
I will have to ignore the case ...

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 9:20 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
Update (Both libs)

- should fix the 'Content-transfer-encoding' case problem

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 1:17 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 2853
Location: United Kingdom
Thanks for the quick fix. :)

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 28, 2007 12:24 pm 
Offline
User
User

Joined: Thu Dec 22, 2005 2:43 pm
Posts: 64
Location: Chios, Greece
Hi gnozal, let me be another one thanking you for your great lib :)

Any chance to provide us with a version that works with Unicode programs?

Thank you very much in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 28, 2007 5:46 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jun 02, 2005 3:55 am
Posts: 505
Location: U.S.A.
I just tried this and it works; however, I noticed the Debug information (from the example in the Help file for this lib) states I have 41 Emails when I only had one (a test one I had just typed up).

Ideas?

TIA

_________________
Intrigued - Registered PureBasic, lifetime updates user


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 29, 2007 9:08 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
Frontier wrote:
Any chance to provide us with a version that works with Unicode programs?
It was a big work to get a working unicode PureSMTP or PureZIP. I will try to do it when I have time and some POP3 servers to test.
Intrigued wrote:
noticed the Debug information (from the example in the Help file for this lib) states I have 41 Emails when I only had one (a test one I had just typed up)
The PurePOP3_CountMessages() simply sends "STAT" + #CRLF to the POP3 server and parses the answer (wich is like '+OK NbMessages TotalSize' -> +OK 48 447343).
Maybe you could get some more information on this issue by activating the trace mode and looking in the log files to see what the server answers ?

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 29, 2007 11:47 am 
Offline
User
User

Joined: Thu Dec 22, 2005 2:43 pm
Posts: 64
Location: Chios, Greece
gnozal wrote:
Frontier wrote:
Any chance to provide us with a version that works with Unicode programs?
It was a big work to get a working unicode PureSMTP or PureZIP. I will try to do it when I have time and some POP3 servers to test.

Anything I can do to help you? I am proficient in C/C++ and Unicode, as I program mainly for Windows CE Devices.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 336 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 23  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


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