pop3proxy

BrokenClock brokenclock at free.fr
Mon May 2 10:05:13 EDT 2005


Hello every body,

Here is a python newbie! I've choose it to make a pop3 proxy - I want to 
filter content between a pop3 client and a pop3 server, and I have no 
control on the server...
First, I wanted to do an non-filtering, just logging, mono-thread proxy 
to make some test..
Based on the RFC 1939 (http://www.faqs.org/rfcs/rfc1939.html) (in 
particular the item 5), I was expecting some output, but did not get it...
In fact, I expected to see the message, but I did not see it... only the 
  command to retrieve it. On the other hand, the message is well receipt 
in my mail client.
An other point is that all this seems to work well with short messages, 
but difficulties appear when messages go bigger. I think it is due to 
the parameter of recv, but I don't know how to set it.
So here are my two questions:
1-why do not I see the message in my output, and how could I do to see 
and handle it?
2-how should I set the parameter of recv to handle big messages?

Any help would we very appreciate.

Cheers,

Brokenclock

Here is the code:
 >
import socket

LOCALHOST = '192.168.31.202'		# This is me
REMOTEHOST = 'pop.fr.oleane.com'	# The remote host
PORT = 110				# pop3 port
while 1:
	SocketServer = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	SocketServer.bind((LOCALHOST, PORT))
	SocketServer.listen(1)
	Connexion2Client, ClientAddress = SocketServer.accept()
	print '#', ClientAddress,' connected'
	ClientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	ClientSocket.connect((REMOTEHOST, PORT))
	print '#', REMOTEHOST, ' connected'
	while 1:
		DataFromServer = ClientSocket.recv(5896230)
		print REMOTEHOST,'> ',DataFromServer
		Connexion2Client.send(DataFromServer)
		DataFromClient = Connexion2Client.recv(5896230)
		print ClientAddress,'> ',DataFromClient
		if DataFromClient==" QUIT": print 'QUIT received from client'
		ClientSocket.send(DataFromClient)
		if not DataFromClient: break
	ClientSocket.close()
	Connexion2Client.close()
 >eof


Here the output:
 >
C:/Python24/pythonw.exe -u  "C:/Python24/Scripts/pop3proxy3.py"
# ('192.168.31.202', 2345)  connected
# pop.fr.oleane.com  connected
pop.fr.oleane.com >  +OK pop1.clb.oleane.net POP3 Oleane Mail Server Ready

('192.168.31.202', 2345) >  CAPA

pop.fr.oleane.com >  +OK Capability list follows
TOP
USER
RESP-CODES
AUTH-RESP-CODE
PIPELINING
UIDL
IMPLEMENTATION omail-1.3.1
.

('192.168.31.202', 2345) >  USER Mondia-26 at wincanto.fr.fto

pop.fr.oleane.com >  +OK User name accepted, password please
Username

('192.168.31.202', 2345) >  PASS password

pop.fr.oleane.com >  +OK 1 messages (1631 octets)

('192.168.31.202', 2345) >  STAT

pop.fr.oleane.com >  +OK 1 1631

('192.168.31.202', 2345) >  LIST

pop.fr.oleane.com >  +OK 1 messages (1631 octets)
1 1631
.

('192.168.31.202', 2345) >  UIDL

pop.fr.oleane.com >  +OK Unique-ID listing follows
1 42762947a48018100000065f
.

('192.168.31.202', 2345) >  RETR 1

pop.fr.oleane.com >  +OK pop1.clb.oleane.net chpounz the connection. 
Have a nice day!

('192.168.31.202', 2345) >
 >eof



More information about the Python-list mailing list