pop3 mail download - using python.org example

K

Kevin F

i'm trying to this this code to access my pop server but it only prompts
for a password and not a username, how do i get it to ask for my
username as well?


##from http://docs.python.org/lib/pop3-example.html

import getpass, poplib

M = poplib.POP3('localhost')
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
 
A

Alex Martelli

Kevin F said:
i'm trying to this this code to access my pop server but it only prompts
for a password and not a username, how do i get it to ask for my
username as well?

getpass.getuser() doesn't prompt, it gets your username from the
environment or the OS. If you want a raw input function that prompts,
instead of that call rawinput('User: ') ...


Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top