1. Home
  2. Computing & Technology
  3. Python

Using poplib to Access a POP3 Mail Server

From Al Lukaszewski, for About.com

2 of 4

Logging Into a POP3 Mailbox

The following methods are used to log into a POP3 account.
  • p.pass_(password): Sends a password password to the server. The server then replies with a response ('+OK' or '-ERR'). If the login is successful, the response will also include the number of messages in the mailbox and the mailbox's size in bytes.
  • p.user(username): Used to specify a username username for logging into the server. If this is not used, the default is to use the name associated with the calling process or user.
NB: When using POP3, remember that the mailbox is locked until you call quits by sending 'Quit' (see p.quit() under 'Managing a POP3 Mailbox'). This obviously prohibits other mail from being delivered. Rather it queues up on a server somewhere. Best practice is to login, pull down all the messages, and quit - leaving the box locked for as little time as possible.
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. Python Library
  5. Python Programming - Python Library - poplib Module - Logging Into a POP3 Mailbox with poplib

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

All rights reserved.