Lazarus
Home
Forum
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
Indy POP3
Downloads
Daily Snapshots
FAQ
Wiki
Bugtracker
IRC channel
Developer Blog
Follow us on Twitter
Mailing List
Free pascal
Other languages
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
About donations (wiki)
Bookstore
Lazarus, the complete guide
Search
Advanced search
« previous
next »
Print
Pages: [
1
]
2
Author
Topic: Indy POP3 (Read 3089 times)
exdatis
Full Member
Posts: 192
Indy POP3
«
on:
July 22, 2012, 06:47:07 pm »
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!
«
Last Edit: July 22, 2012, 06:49:37 pm by exdatis
»
Logged
exdatis
Full Member
Posts: 192
Re: Indy POP3
«
Reply #1 on:
July 24, 2012, 07:30:19 am »
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.
Logged
theo
Global Moderator
Hero Member
Posts: 1841
Re: Indy POP3
«
Reply #2 on:
July 24, 2012, 11:38:46 am »
I would recommend Synapse:
http://synapse.ararat.cz/doku.php/public:howto:pop3sample
Logged
exdatis
Full Member
Posts: 192
Re: Indy POP3
«
Reply #3 on:
July 25, 2012, 07:32:00 am »
Thank you very much, theo! I'll try.
Logged
exdatis
Full Member
Posts: 192
Re: Indy POP3
«
Reply #4 on:
July 25, 2012, 09:13:02 am »
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
Logged
exdatis
Full Member
Posts: 192
Re: Indy POP3
«
Reply #5 on:
July 27, 2012, 07:34:55 am »
It also works great on windows(win7 ultimate 32bit).
Regards.
Logged
teos
Full Member
Posts: 129
Re: Indy POP3
«
Reply #6 on:
August 21, 2012, 01:03:54 am »
Indy is just as good or better. The error you refer to is described in the comment you post.
Logged
exdatis
Full Member
Posts: 192
Re: Indy POP3
«
Reply #7 on:
August 21, 2012, 07:57:47 am »
Hi, teonieuwlande,
I am sure that Indy is excellent choice, but I didn't solve the problem.
Suggestion? Example?
Thank you.
Regards.
Logged
JD
Hero Member
Posts: 858
Re: Indy POP3
«
Reply #8 on:
August 21, 2012, 10:03:37 am »
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
«
Last Edit: August 21, 2012, 10:07:58 am by JD
»
Logged
exdatis
Full Member
Posts: 192
Re: Indy POP3
«
Reply #9 on:
August 21, 2012, 10:32:31 am »
Thank you very much, JD!
This is very useful information, thank you.
Best regards.
Logged
teos
Full Member
Posts: 129
Re: Indy POP3
«
Reply #10 on:
August 21, 2012, 10:51:40 am »
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. :-)
Logged
exdatis
Full Member
Posts: 192
Re: Indy POP3
«
Reply #11 on:
August 21, 2012, 12:30:25 pm »
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!
«
Last Edit: August 21, 2012, 12:38:31 pm by exdatis
»
Logged
JD
Hero Member
Posts: 858
Re: Indy POP3
«
Reply #12 on:
August 21, 2012, 12:38:34 pm »
Quote from: teonieuwlande on August 21, 2012, 10:51:40 am
Indy 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
«
Last Edit: August 21, 2012, 12:42:36 pm by JD
»
Logged
exdatis
Full Member
Posts: 192
Re: Indy POP3
«
Reply #13 on:
August 21, 2012, 12:43:09 pm »
Thanks again!
Regards!
Logged
teos
Full Member
Posts: 129
Re: Indy POP3
«
Reply #14 on:
August 21, 2012, 02:38:42 pm »
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.
«
Last Edit: August 21, 2012, 04:33:36 pm by teonieuwlande
»
Logged
Print
Pages: [
1
]
2
« previous
next »
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
Indy POP3
Recent
How do I resolve Debbuger...
by
reltek
[
Today
at 10:10:25 pm]
Circular unit references ...
by
Martin_fr
[
Today
at 09:40:17 pm]
Problem with TScrollBox i...
by
zeljko
[
Today
at 09:02:57 pm]
Slow calls to DLL ?
by
Martin_fr
[
Today
at 08:25:14 pm]
How to devide a String
by
typo
[
Today
at 07:38:21 pm]
Longshot - Briefly move a...
by
jwdietrich
[
Today
at 07:27:56 pm]
How to get the real file ...
by
marcov
[
Today
at 05:20:36 pm]
Parallel archiver was upd...
by
JuhaManninen
[
Today
at 05:10:32 pm]
Tbutton.AccessibleDescrip...
by
Martin_fr
[
Today
at 04:34:59 pm]
TMemo Not Responding Afte...
by
Dytlyf
[
Today
at 04:19:32 pm]