[Tutor] Help
Tarasub
Tarasub <Taradino@subdimension.com>
Sun, 20 Jan 2002 10:35:02 +0100
kjc> Can't seem to figure out how-to access a POP3 account. I can get a
kjc> connected message, but can go no further to retrieve messages.
kjc> Any suggestions? I'm using Python 2.1
kjc> Keith
A very simple example:
import poplib
pop = poplib.POP3('server', 'port')
pop.user('username')
pop.pass_('password')
num_msg_list = len(pop.list()[1])
# Iterate over all messages.
for i in range(num_msg_list):
# Loop over all lines of the message, except index 1, which is the response.
for j in pop.retr(i+1)[1]:
# Print the line.
print j
More can be found in the manual with poplib.