IdPOP3Server

IdPOP3Server

Post by F. Cocquy » Tue, 28 Oct 2003 01:36:11


Hi group,

first of all: am a novice in POP3 protocol.
I have been experimenting with pop3 client, and that went very well (no
problems so far) but when I try to make a POP3 server using IdPOP3Server
component, I cannot make it to work. I constantly am getting errors. Is
there somewhere I can find a good working example of a basic pop3 server
using the IdPOP3Server component? I have already taken a look at the example
that can be found in the examples from Indy but this is a non working
version, and I don't find it very clear on how to proceed.

Thanks,
F. Cocquyt
 
 
 

IdPOP3Server

Post by Team » Tue, 28 Oct 2003 06:47:13


Please elaborate. Just saying "it doesn't work" says nothing at all about
the actual problems you are having. Please show your actual code and
indicate what the actual error messages are and which lines of code they
refer to.


Gambit

 
 
 

IdPOP3Server

Post by F. Cocquy » Wed, 29 Oct 2003 01:32:34

I get an error when my client connects to my server. The program stops at
this rule:
Panels[SmAantalBerichten].Text := inttostr(DMPop3.IdPOP3.CheckMessages) + '
berichten';
With the error :" 'login' is not a valid integer value" . But I don't
understand where this 'login' comes from. (Checkmessages returns a integer
if I am not mistaken) I don't get this error when I connect with the PoP3
Server from my ISP. So I think the error is with the Pop3Server I am trying
to make.

F Cocquyt


"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM > schreef in
 
 
 

IdPOP3Server

Post by Team » Wed, 29 Oct 2003 03:42:33


'
understand
not mistaken)

Yes, it does return an int, but internally it has to first receive a string
from the server containing the data that it will parse. So the error is
that the server you are connecting is to sending the wrong data.

Please post a more complete code snippet of exactly how you are using the
TIdPOP3, from the time you connect to the time it errors. Also, what are
your exact property settings for the TIdPOP3?


Gambit
 
 
 

IdPOP3Server

Post by F. Cocquy » Wed, 29 Oct 2003 05:27:23

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM > schreef in


const
SmVerbonden = 0;
SmAantalBerichten =1;

...

procedure TfrmMain.btnVerbindenClick(Sender: TObject);
begin
with DMPop3.IdPOP3 do
begin
//todo: functie schrijven van Verbreken
if Connected then Disconnect;
Host:= DMGegevens.cdsGegevens.FieldValues['Server'];
Username:= DMGegevens.cdsGegevens.FieldValues['Gebruiker'];
Password:= DMGegevens.OphalenPW;
Connect(-1);
MemoResponse.Lines.Add(DMPop3.IdPOP3.LastCmdResult.Text.Text;);
if Connected then
begin
with StatusBar1 do
begin
Panels[SmverBonden].Text := 'Verbonden';
Panels[SmAantalBerichten].Text :=
inttostr(DMPop3.IdPOP3.CheckMessages) + ' berichten'; //ERROR
end;
OpzoekenMail;
MemoResponse.Lines.Add(DMPop3.IdPOP3.LastCmdResult.Text.Text);
end;
end;
end;

procedure TfrmMain.OpzoekenMail;
var
Berichtje:TIdmessage;
i,Aantal:integer;
LijstItem:TListItem;
begin
if not DMPop3.IdPOP3.Connected then exit;
Aantal := DMPop3.IdPOP3.CheckMessages;
for i := 1 to Aantal do
begin
try
Berichtje := TIdMessage.Create(self);
DMPop3.IdPOP3.RetrieveHeader(i,Berichtje);
with LvBerichten do
begin
Lijstitem:=Items.Add;
Lijstitem.Caption := (Berichtje.From.Address);
LijstItem.subitems.add(Berichtje.Subject);
LijstItem.subitems.Add(Berichtje.MsgId);
end;
finally
Berichtje.Free;
end;
end;
end;

in order to connect to the server I use Host:= '127.0.0.1' and for the user
and password I use a simple random value (my server doesn't check the
pw/user yet). My question remains the same, where and how does the server
send his data back to the client. Is there a document or white paper I can
read In order to better understand the IdPOP3Server Component? Can I
visualize the messages the server recieves from a client? (Like the
lastCmdResult.Text from the IdPop3 component).
 
 
 

IdPOP3Server

Post by Team » Wed, 29 Oct 2003 05:47:18


Wrap the call to CheckMessages into a try...except block and then see what
the LastCmdResult property actually contains, to see why the parsing is
failing.


Do you mean that you are writing your own POP3 server as well? If so, then
please show that code as well. I would suspect that because you are not
actually handling the username/password yet, then you are messing up the
response sequence for the TIdPop3, since TIdPOP3 is going to issue "USER"
and "PASS" commands whether your server is handling them or not. If you not
validating the login and setting the Transaction state accordingly, that
will probably cause the "STAT" command handler to fail, ("STAT" is the
command that CheckMessages() sends to the server).


Use the OnBeforeCommandHandler event.


Gambit
 
 
 

IdPOP3Server

Post by F. Cocquy » Thu, 30 Oct 2003 05:03:28


"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM > schreef in


then

The only thing I have writen sofar is: (As I said earlier: I am still
trying to understand the TIdPOP3Server component and how POP3 servers
have to act, or whitch commands it has to send)

procedure TDMServer.IdPOP3ServerCheckUser(AThread: TIdPeerThread;
LThread: TIdPOP3ServerThread);
begin
//user en PW check nog implementeren
LThread.State := Trans;
end;

procedure TDMServer.IdPOP3ServerConnect(AThread: TIdPeerThread);
begin
AThread.Connection.WriteLn('+OK De server wacht');
end;


procedure TDMServer.IdPOP3ServerSTAT(ASender: TIdCommand);
begin
ASender.Thread.Connection.WriteLn('+OK 1 40');
end;
 
 
 

IdPOP3Server

Post by Team » Thu, 30 Oct 2003 05:24:08


You should not be doing that. The server has a Greeting property that
already handles that, thus you are putting 1 response too many into the
socket, thus you are going to throw off the conversation between clients and
the server. If you really want to say "De server wacht" upon client
connection, then you need to update the Greeting property instead.


Gambit