Re: [twsocket] POP3 and fetching messages?
If I want to fetch all of the messages on the server, can I use something like MsgNum = 1 up to MsgCount or can the actual number change so I have to do a combination of List and Retr? Most POP3 servers offer a snapshot of the mailbox when it is opened, and ignore any new email that arrives subsequently, so STAT, LIST, UIDL and RETR all use the same message numbers. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] POP3 and fetching messages?
You can ignore this. I found this after some wider search in the archive.. :) Also updated the wiki.. :) -Original Message- From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On Behalf Of Fredrik Larsson Sent: den 8 mars 2011 15:25 To: 'ICS support mailing' Subject: [twsocket] POP3 and fetching messages? Hi, I haven't used the POP3-component before so I need a little help. If I want to fetch all of the messages on the server, can I use something like MsgNum = 1 up to MsgCount or can the actual number change so I have to do a combination of List and Retr? Regards, Fredrik. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 and lastresponse
Arno Garrels wrote: Zvone wrote: IMO the component should clear LastResponse on before connect. Maybe it should, but what it does is different story :) I checked in a few changes today, it's rev #600: Log: Pop3Prot V6.08 Moved HMAC-MD5 code to OverbyteIcsMD5.pas. Ensure that var LastResponse is cleared before Connect. Added a public read/write property LastError (as requested by Zvone), it is more or less the last ErrCode as passed to event OnRequestDone and reset on before each request. SmtpProt V7.32 Moved HMAC-MD5 code to OverbyteIcsMD5.pas. MD5 V7.01 Added HMAC_MD5 routine from OverbyteIcsSmtpProt.pas and MD5DigestToHex functions. Sha1 V2.02 Added SHA1DigestToHex functions. DigestAuth V1.01 Uses OverbyteIcsMD5.MD5DigestToLowerHexA. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 and lastresponse
Zvone wrote: IMO the component should clear LastResponse on before connect. Maybe it should, but what it does is different story :) Yes, it has to be fixed IMO. So what about a numeric property LastErrorNumber? There is no such property nowhere in pop3 (or in any ICS file). That was a feature suggestion for a new property LastRequestError and perhaps a new property LastRequestType. Will look at it more closly when I have some more time. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 and lastresponse
While Timeout works rather nice as far as Idle version goes, connect version is usually preceded by Windows built-in timeout An application can not cleanly stop a TCP connection attempt, you have to wait for Windows to timeout, usually 40 seconds unless there is an error of some sort earlier. To avoid this timeout, you need to try and ping the host first, which can have a much shorter timeout, although ping may be blocked so it needs to be optional. As for Throttle, it works but rather strangely. If I set limit to 1 and timer to 1000 it should pass 1 byte every 1000ms Throttle is designed to slow down megabyte speeds to kilobytes, not to send one byte per second. It does not deal with partial buffers. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 and lastresponse
Hello, Zvone wrote: I found something that might also be issue with pop3 component. If you check one pop3 account and end the session usually LastResponse will be some ending message like +OK sayonara. But if you then reinitialize pop3 for another account and this account fails to connect, for example due to timeout you get for example -ERR Connection refused (Winsock error #10061) but LastResponse is still +OK sayonara although it should be invalidated and set to empty string. Or, there should be IMO a method ClearLastResponse as LastResponse is not a writeable property right now. Checking on both messages (LastError and LastResponse) is useful for debugging purposes so they should be a possibility to manually (by calling ClearLastResponse) or automatically invalidate LastResponse. IMO the component should clear LastResponse on before connect. Furthermore, although Error code is accessible in for example OnRequestDone it is not accessible within the pop3 component and the code may sometimes be 10061 which is Winsock code or 500 which is pop3 component code. Nothing that can't be done with little RegEx on LastError but why not publishing this as well? So what about a numeric property LastErrorNumber? [..] As for Throttle, it works but rather strangely. If I set limit to 1 and timer to 1000 it should pass 1 byte every 1000ms and accumulate the rest in internal buffer right? Well it doesn't work like if you do something like SendStr(Some large string here) it will send entire string and then wait for 1000 ms rather than sending just one byte every 1000 ms. At least this is how throttle should work - send a maximum of Limit bytes every Timer interval and if more is available, store in internal buffer for sending later. It may be tricky to implement as data could accumulate in memory but not sure about that one. It is neither intended to support such small values nor to work very accurate. Currently, as Angus said, it doesn't control buffer sizes. However the following should do the trick IMO, if I haven't missed something, worth to be tested anyway: function TCustomThrottledWSocket.RealSend(var Data: TWSocketData; Len: Integer): Integer; begin if FBandwidthEnabled and (Len 0) and (FBandwidthCount + LongWord(Len) FBandwidthMaxCount) then Len := (FBandwidthMaxCount - FBandwidthCount) + 1; // Ensure Len 0 Result := inherited RealSend(Data, Len); if FBandwidthEnabled and (Result 0) then begin Inc(FBandwidthCount, Result); if (FBandwidthCount = FBandwidthMaxCount) and (not FBandwidthPaused) then begin FBandwidthPaused := TRUE; Pause; end; end; end; {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} function TCustomThrottledWSocket.Receive(Buffer: TWSocketData; BufferSize: Integer): Integer; begin if FBandwidthEnabled and (BufferSize 0) and (FBandwidthCount + LongWord(BufferSize) FBandwidthMaxCount) then BufferSize := (FBandwidthMaxCount - FBandwidthCount) + 1; // Ensure BufferSize 0 Result := inherited Receive(Buffer, BufferSize); if FBandwidthEnabled and (Result 0) then begin Inc(FBandwidthCount, Result); if (FBandwidthCount FBandwidthMaxCount) and (not FBandwidthPaused) then begin FBandwidthPaused := TRUE; Pause; end; end; end; -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 and lastresponse
IMO the component should clear LastResponse on before connect. Maybe it should, but what it does is different story :) The following fails also with non-sync version but sync is easier to copy-paste. //-- SyncPop3Cli-Host = put-valid-server-here; SyncPop3Cli-UserName = put-valid-username; SyncPop3Cli-PassWord = put-valid-password; SyncPop3Cli-ConnectSync(); SyncPop3Cli-UserSync(); SyncPop3Cli-PassSync(); SyncPop3Cli-StatSync(); SyncPop3Cli-QuitSync(); // Here you should have +OK goodbye or whatever in LastResponse MessageBox(NULL,(LastResponse:+SyncPop3Cli-LastResponse+\r\nLastError:+ SyncPop3Cli-ErrorMessage).c_str(), Info, MB_OK); SyncPop3Cli-ClearErrorMessage(); //SyncPop3Cli-LastResponse = ; // What should be done SyncPop3Cli-Host = www.google.com; // Simulate bad server SyncPop3Cli-Port = 81; // Behind firewall SyncPop3Cli-UserName = a; SyncPop3Cli-PassWord = b; SyncPop3Cli-ConnectSync(); // +OK goodbye from last connection is still here MessageBox(NULL,(LastResponse:+SyncPop3Cli-LastResponse+\r\nLastError:+ SyncPop3Cli-ErrorMessage).c_str(), Info, MB_OK); //-- So what about a numeric property LastErrorNumber? There is no such property nowhere in pop3 (or in any ICS file). something, worth to be tested anyway: [...] I'll take a look and test this code soon enough. Thanks. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3, buffer and character encoding
Zvone wrote: TBytes was the datatype to be used. However that would break backwards compatibility since historically string was used everywhere. That all was no problem, however the rule is: DO NOT BREAK BACKWARDS COMPATIBILITY and that is where the problems begin. Well you've already broken this rule by using UnicodeString as return type The ICS components use string since the beginning, it just happend in RDS 2009 that its mapping changed from AnsiString to UnicodeString. Only C++Builder packages always used the mapped type explicitly. so I don't see a big deal here. Also ICS 7 is used by users that need to recompile their code in D2009/2010 so they do have to adapt their code anyway as it won't work properly with D2009 not just with ICS. No, in Delphi there are no interface changes. Properties, signatures of methods and event handlers did not change. That is different in C++Builder where everything changed from AnsiString to UnicodeString. For compatibility purposes you have ICS 6 and 5. And it's not a big problem - I have 2 ideas then to satisfy everybody and improve codepages compatibility: Idea 1: Why not introduce TPop3Cli.LastResponseTb which would be identical to LastResponse except different type (TBytes)? Yes, probably we should introduce a new property LastRawResponse: TBytes as workaround. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3, buffer and character encoding
Hello Zvone, Yes, the Unicode implementation of the POP3 client is weak. It converts the bytes received to Unicode with current Ansi system codepage. This is direct result of ICS rule #1 to not break backwards compatibility. However, as long as this codepage was one of the windows-xyz, single byte character sets converting back to Ansi with the same codepage should work without data loss and give you back the raw bytes (hopefully). This won't work, for example, with Japanese locale settings. Note that in MIME headers 8-bit characters are not allowed! Email clients must encode 8-bit characters in header lines properly. MIME text parts might include 8-bit characters with a charset specified in the content-type header, in those cases the (AnsiString) text content has to be converted to Unicode with the charset specified. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3, buffer and character encoding
Zvone wrote: However, as long as this codepage was one of the windows-xyz, single byte character sets converting back to Ansi with the same codepage should work without data loss and give you back the raw bytes (hopefully). This won't work, for example, with Japanese locale settings. But there is a string type for that purpose. It is called RawByteString. It is defined as AnsiString($) which in effect means it is an ansistring with no encoding attached to it so you can use it to transfer data from functions and avoid codepage conversions. The purpose of type RawByteString is to avoid implicit string casts. As you know, the compiler is codepage aware of AnsiStrings since 2009+. Use of RawByteString makes sense as parameter, especially to avoid writing plenty of overloades, nothing else. Yes, by default it uses default system code page for conversions to Unicode. RawByteString is a single-byte character type but unlike AnsiString it does not have a specific encoding attached to it. So that means it can be used to pass values to and from functions that will do UnicodeConversions. It is not indended to be used for storing data, just mostly for input/output of functions as the official documentation specify. RawByteStrings are not implcitly converted by compiler magic, that's all, and this type is not documented well. So my best bet is that it would be the best to receive raw byte buffer (unsigned char or BYTE type) and then place it into RawByteString and return that value. This should avoid conversions. TBytes was the datatype to be used. However that would break backwards compatibility since historically string was used everywhere. In your own functions you can cast RawByteString as input type and use conversion functions to convert from RawByteString to any codepage you like (or store it as binary data). There are some functions that do this I think the ones you need are SetCodePage() and StringCodePage(). That all was no problem, however the rule is: DO NOT BREAK BACKWARDS COMPATIBILITY and that is where the problems begin. Other than that, AnsiString can be defined in various codepages for example you can declare a typedef AnsiStringT28591 Latin1String; and store data in Latin1String type - this will ensure that the codepage conversions are always in identical codepage and not dependent on the system code page. I think the ICS components need a lot more changes (basic design changes). -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3, buffer and character encoding
TBytes was the datatype to be used. However that would break backwards compatibility since historically string was used everywhere. That all was no problem, however the rule is: DO NOT BREAK BACKWARDS COMPATIBILITY and that is where the problems begin. Well you've already broken this rule by using UnicodeString as return type so I don't see a big deal here. Also ICS 7 is used by users that need to recompile their code in D2009/2010 so they do have to adapt their code anyway as it won't work properly with D2009 not just with ICS. For compatibility purposes you have ICS 6 and 5. And it's not a big problem - I have 2 ideas then to satisfy everybody and improve codepages compatibility: Idea 1: Why not introduce TPop3Cli.LastResponseTb which would be identical to LastResponse except different type (TBytes)? Idea 2 (probably better one): Why not introduce TPop3Cli.ResponseType enum which you could choose if you want TBytes or String and the default if you don't use it would be String for backward compatibility? Both changes should be relatively easy to implement like a few lines of code... and you could apply them for other components as well that may have issues with Unicode. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 component not ready - Bug in TPop3Cli
On Jan 17, 2008, at 07:34, [EMAIL PROTECTED] wrote: it didnt fix the issue, got a pop3 not ready exception today. Can you post some code so that we know how you tried to fix it? dZ. -- DZ-Jay [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 component not ready - Bug in TPop3Cli
DZ-Jay wrote: Can you post some code so that we know how you tried to fix it? The bug I found is the Special processing for Quit below. procedure TCustomPop3Cli.TriggerRequestDone(Error: Word); begin == (* { Special processing for Quit (Roger Morton 24-12-99) } if FRequestType = pop3Quit then begin if FWaitingOnQuit then { When the second RqDone arrives (from WSocketSessionClosed), } { treat it as a normal event by setting a zero Error code } Error := 0 else begin { When the first RqDone arrives, set the FWaitingOnQuit flag so } { we're ready to handle a second RqDone.} { Take no other action (in particular, we don't advise the user } { that the first RqDone has happened) } FWaitingOnQuit := True; Exit; end; { Fall down here for all normal RqDone, and after the second RqDone } { following a Quit } FWaitingOnQuit := False; end; == *) This code prevents that RequestDone fires in case the server doesn't send a response to the Quit command, and thus the Pop3State is never reset properly. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 component not ready - Bug in TPop3Cli
AG It helps alot to post a short message when you either think AG the problem is resolved or not. Thanks. it didnt fix the issue, got a pop3 not ready exception today. AG -- AG Arno Garrels [TeamICS] AG http://www.overbyte.be/eng/overbyte/teamics.html i also hope that the bug gets eliminated in the next release by FPIETTE. i don't really like using custom-patched components. -- Mit freundlichen Grüßen [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 component not ready - Bug in TPop3Cli
[EMAIL PROTECTED] wrote: AG It helps alot to post a short message when you either think AG the problem is resolved or not. Thanks. it didnt fix the issue, got a pop3 not ready exception today. You did not provide any further information, not ready exceptions may happen, i.e. due to incorrect component use. So I'm helpless. I use TPop3Cli in an NT service application that checks for and downloads mails in intervals since several years now w/o any problem. However I'm starting a new session by calling Abort (to work around the bug I mentioned), this works very reliable though it's not nice. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html AG -- AG Arno Garrels [TeamICS] AG http://www.overbyte.be/eng/overbyte/teamics.html i also hope that the bug gets eliminated in the next release by FPIETTE. i don't really like using custom-patched components. -- Mit freundlichen Grüßen [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] pop3 component not ready
[EMAIL PROTECTED] wrote: procedure TMailAlert.Pop3ClientRequestDone; begin if (FPop.connected) and (CheckError) then begin FPop.quit; exit; end; ... what could be the cause that the component is not ready after the error ? After sending command Quit you should receive a server response. When it's received you may either close or abort the connection yourself or wait until the server drops the connection. Anyway start next connection attempt only when you are not connected, means after SessionClosed fired. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] POP3
Hello: I haven't worked with POP3 authentication, so I can't answer those questions, but at least I can give you an answer to your first question: --- quote: What is the difference between Open and Connect? Is it that Connect simply gets the server's attention, so to speak, such that User, Pass etc can be sent as required, while Open encapsulates the process into one step? Or am I way off with this? --- end. You are absolutely correct. -dZ. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] POP3
Hi, You are absolutely correct. Thanks for that dZ! Rob. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] POP3 Client - changing folders on the server
Hello: With POP3, there is no notion of folders or any organization of messages. It is just reads a single file. When you said that your ISP added a spam folder, what do you mean? Did they add this to a WebMail application? If so, this has nothing to do with the POP3 server. dZ. On Feb 8, 2006, at 17:09, John R. Dicks wrote: I have written an ap using the POP3 component to access mail from my ISP. I can also access my email via the internet. The ap works perfectly, but my ISP has recently added a spam folder into which it places anything it considers to be spam. Is there a way to change to that folder using the POP3 component so I can check the headers in case something has gone in there that I want? - or how else can I do it? Thanks John -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] POP3 Client - changing folders on the server
I have written an ap using the POP3 component to access mail from my ISP. I can also access my email via the internet. The ap works perfectly, but my ISP has recently added a spam folder Effectively the mail is being put into a separate mailbox, you just log into that mailbox instead. My ISP calls it greymail.xx instead is mail.xx. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be