1. Home
  2. Computing & Technology
  3. Python

Retrieving POP3 Email with poplib

From Al Lukaszewski, for About.com

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.

Explore Python
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Python
  4. Web Development
  5. Python Programming - Retrieving Email - Pop POP3 with poplib - Retrieving POP3 Email with poplib

©2009 About.com, a part of The New York Times Company.

All rights reserved.