1. Computing & Technology

Retrieving POP3 Email with poplib

From , former About.com Guide

1 of 5

Getting the Username

Once you are familiar with managing a POP3 mailbox with poplib and getting login information with getpass, you can use the two together to access (or "pop") any mailbox on-the-fly. First things first, import the relevant modules:


import getpass, poplib
Then get the username. Using Python's built-in input() function here will consistently result in errors. input() treats all strings as variable names - even email logins. Therefore, you need to use raw_input() to ensure the string is not misunderstood.

user = raw_input('Username:')
This gives the user a prompt of "Username:" and places the ensuing input into a variable user.

©2012 About.com. All rights reserved.

A part of The New York Times Company.