Indy POP3 lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- exdatis · 2012-07-22 16:47 Hi there! Indy IdPOP3 and ? What components are necessary to connect and count messages? e.g. procedure TForm1.Button1Click(Sender: TObject); var   msgs : Integer; begin   IdPOP3_1.Host:= 'pop.googlemail.com';   IdPOP3_1.Port:= 995;   IdPOP3_1.Username:= 'user@google.com';   IdPOP3_1.Password:= 'password';   try     IdPOP3_1.Connect;     msgs:= IdPOP3_1.CheckMessages;     ShowMessage(Format('Msg: %d', [msgs]));     IdPOP3_1.Disconnect;   except     on E : Exception do     begin       ShowMessage(E.Message);       Exit;     end;   end; end;          Thanks! ---------------------------------------------------------------------- exdatis · 2012-07-24 05:30 I tried INDY SVN revision 4774 (21-7-2012) I've got error. _________________________________ procedure TForm1.Button1Click(Sender: TObject); begin IdPOP3_1.Host:= 'pop.googlemail.com'; IdPOP3_1.Username:= 'some_user'; IdPOP3_1.Password:= 'pwd'; IdPOP3_1.Port:= 995; try IdPOP3_1.Connect; Application.ProcessMessages; except on E : Exception do begin ShowMessage(E.Message); Exit; end; end; ShowMessage('Success'); end; procedure TForm1.IdPOP3_1Connected(Sender: TObject); var msgs : Integer; begin ShowMessage('I am here');//works Application.ProcessMessages; msgs:= IdPOP3_1.CheckMessages;//doesn't work or something else Application.ProcessMessages; ShowMessage(Format('Msgs: %d', [msgs])); end; ___________________________________________________ --Comment (IdIOHandler unit) {-- If this is a CLIENT The server side of this connection has disconnected normaly but your client has attempted to read or write to the connection. You should trap this error using a try..except. Please see the help file for possible further information. // ************************************************************* *) raise EIdConnClosedGracefully.Create(RSConnectionClosedGracefully); ----} Opinions? Some useful link? Thanks. Regards. ---------------------------------------------------------------------- theo · 2012-07-24 09:38 I would recommend Synapse: http://synapse.ararat.cz/doku.php/public:howto:pop3sample ---------------------------------------------------------------------- exdatis · 2012-07-25 05:32 Thank you very much, theo! I'll try. ---------------------------------------------------------------------- exdatis · 2012-07-25 07:13 Works excellent! Thank you so much, theo! Easy and useful! Regards! p.s. I tried pop and smtp, fantastic! XUbuntu 32bit, C.T 2.7 ---------------------------------------------------------------------- exdatis · 2012-07-27 05:34 It also works great on windows(win7 ultimate 32bit). Regards. ---------------------------------------------------------------------- teos · 2012-08-20 23:03 Indy is just as good or better. The error you refer to is described in the comment you post. ---------------------------------------------------------------------- exdatis · 2012-08-21 05:57 Hi, teonieuwlande, I am sure that Indy is excellent choice, but I didn't solve the problem.  Suggestion? Example? Thank you. Regards. ---------------------------------------------------------------------- JD · 2012-08-21 08:03 To get answers to your Indy questions, I suggest you ask the questions on the following forums a) Atozed Hosted Forums http://forums2.atozed.com/viewforum.php?f=7 b) StackOverflow (Indy 10 search) http://stackoverflow.com/search?q=Indy+10 c) Embarcadero Winsock Forums https://forums.embarcadero.com/forum.jspa?forumID=74&start=0 This is because the Indy developers are on these forums and respond to questions like yours daily. I've seen detailed responses to Indy development on multiple platforms and I've benefited greatly from them. That's where I go when I get stuck in my Indy projects.  I don't think any of the Indy developers use the Lazarus forums even though I've tried to invite them over in the past.  JD ---------------------------------------------------------------------- exdatis · 2012-08-21 08:32 Thank you very much, JD! This is very useful information, thank you. Best regards. ---------------------------------------------------------------------- teos · 2012-08-21 08:51 Well.. the comment says that the client writes to a connection that is closed by the server. But more important: your code is not working because Gmail/googlemail uses SSL. What is happening IMHO: your client connects to the Google server and in the connect event sends a command, even though the server disconnected. (If you read the comment you posted, you see that the error is from writing to a connection closed by the server). How to solve this? Google uses SSL/TLS so you need to add that to your code. I will post an example after this answer. Indy IS mature, supports all you need but needs a little getting used to. :-) ---------------------------------------------------------------------- exdatis · 2012-08-21 10:30 Thank you so much! I'll try, as soon as possible. Best regards. p.s. For the first time I tried to write this type of app and I'm lucky, great help! Thanks guys! ---------------------------------------------------------------------- JD · 2012-08-21 10:38 Quote from: teonieuwlande on August 21, 2012, 10:51:40 amIndy IS mature, supports all you need but needs a little getting used to. :-) I agree. It is a large project and has a LOT of stuff. It is installed by default in Delphi since Delphi 6 (DataSnap uses Indy even FireMonkey uses Indy http://stackoverflow.com/questions/7365421/does- delphi-xe2-firemonkey-support-indy-for-cross-platform-apps). In addition, it is upgraded very often. It does take a little getting used to and that is why it is best to contact the developers directly. Someone like Remy Lebeau (or gambit47) reponds to users' questions/problems daily. He was the one who helped me with installing the latest SVN versions of Indy10 in Lazarus. JD ---------------------------------------------------------------------- exdatis · 2012-08-21 10:43 Thanks again! Regards! ---------------------------------------------------------------------- teos · 2012-08-21 12:38 For the curious: Maybe this article helps: http://www.delphifeeds.com/go/s/58867 You need to download some files here (for SSL support). Those are DLL's so this only runs on Windows. [EDIT] the SSL files are on http://indy.fulgan.com/SSL/ [/EDIT] :-) I have explicit added a disconnect, in your code the client would stay connected. Standard coding as I have seen is in a buttonclick or whatever event wich connects, does everthing needed and disconnects again. I doubt if the IDPOP3 component will allow a disconnect in it's connect event. to the uses section of the unit, I added: IdSSLOpenSSL, IdExplicitTLSClientServerBase My code for button1 click: procedure TForm1.Button1Click(Sender: TObject); var   msgs: integer; begin   IdPOP3_1.Host := 'pop.gmail.com';   IdPOP3_1.Username := 'someaccount';   IdPOP3_1.Password := 'somepassword';   IdPOP3_1.Port := 995;   try     IdPop3_1.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(idPop3_1);     IdPop3_1.UseTLS := utUseImplicitTLS;     IdPOP3_1.Connect;     Application.ProcessMessages;     msgs := IdPop3_1.CheckMessages;     ShowMessage(Format('Msgs: %d', [msgs]));     idPop3_1.Disconnect;   except     on E: Exception do     begin       ShowMessage(E.Message);     end;   end;   ShowMessage('Success'); end; This will stop the error and report the number of new messages. Good luck! b.t.w.: application processmessages is not needed here. ---------------------------------------------------------------------- exdatis · 2012-08-21 12:46 Wow, that's it what I need! Thanks! I'm a little busy but I'll try as soon as possible! Thank you! Regards!