[Tutor] POP3 MailBox Access

James Rocks uktechportal at yahoo.co.uk
Tue Mar 27 13:19:40 CEST 2007




Hi,


 


I'm new to this list but not new to Python ... I've been on
and off coding in it for years. Still I remain just a hobbyist :)


 


Recently my interest in Python was rekindled when I started
hosting a game I used to play (VGA Planets or VGAP) and, because I was also a
player in the same game (something frowned upon or at least viewed suspiciously
in some VGAP circles) I wanted to host the game as neutrally as possible so I
set about writing an automatic hosting (AutoHost) program. VGAP is a multi-player,
strategic, space-based play-by-email game where the host runs, generates result
(RST) files, these get sent to the players who then create turn (TRN) files, effectively
a list of commands, that they then return to the host for the next run. 


 


The general idea of my program is that AutoHost runs (on a
separate machine, Windows 200 Professional) the host, sends out the RST files to
the players and waits for them to send their TRN files back. Once a specific
time has passed or all the TRN's have come back the host runs again and in
between AutoHost sends status updates and receipts for submitted TRN's. 


 


I have had some problems ... initially I wasn't able to get mail
functioning at all and was forced to rely on three DOS command line programs
which I called by means of Python's sys (os module) function. In addition I had
a number of issues with the receipt of mail (for some reason unknown to me the
command line utility which had been working after a fashion suddenly decided to
receive attached files as uuencoded text) and I was forced to abandon it as a
means of getting the TRN's and I switched to FTP instead. The program ran as a
series of separate instances fired off by means of an external scheduler. 


 


This worked but was unsatisfactory ... broadly speaking I'm
pleased with the result but I've got a bit fired up and want to improve it. Firstly
I wanted to internalise the scheduler and have since done so using a timer
routine I found on the internet and the program now runs permanently with
events being triggered by that timer. Secondly I wanted to send & receive mail
using Python's own routines ... I have been successful with SMTP sending but
receiving mail still eludes me probably because it is via POP3. Part of the
reason may be because my POP3 user isn't a single ID as such but a sub-mailbox
from my family one i.e. the VGAP user has a username of mailbox+vgap and
requires authentication. 


 


I have used the a number of variations on the following code
with no luck, even though I know there are messages in the box I get back
nothing.


 


]     


]     import getpass, poplib


]     


]     M = poplib.POP3('mail.isp.net')


]     M.user(getpass.getuser())


]     M.pass_(getpass.getpass())


]     numMessages = len(M.list()[1])


]     for i in range(numMessages):


]         for j in
M.retr(i+1)[1]:


]             print j


]     


 


So, if anyone can offer any help I'd appreciate it :)


 


Kyu






	
	
		
___________________________________________________________ 
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070327/e8c871ff/attachment.html 


More information about the Tutor mailing list