POP mailbox scanning : SMTP « Network « Python Tutorial






import getpass, poplib, sys

host = "serverAddress"
user = "userName"
passwd = "password"

p = poplib.POP3(host)
try:
    p.user(user)
    p.pass_(passwd)
except poplib.error_proto, e:
    print "Login failed:", e
    sys.exit(1)
status = p.stat()
print "Mailbox has %d messages for a total of %d bytes" % (status[0], status[1])
for item in p.list()[1]:
    number, octets = item.split(' ')
    print "Message %s: %s bytes" % (number, octets)
p.quit()








21.11.SMTP
21.11.1.Sending Email Using SMTP
21.11.2.Retrieving Email from a POP3 Server
21.11.3.SMTP and POP3 Example
21.11.4.SMTP transmission with authentication
21.11.5.Basic SMTP transmission
21.11.6.SMTP transmission with debugging
21.11.7.POP mailbox downloader
21.11.8.POP mailbox scanning
21.11.9.POP connection and authentication
21.11.10.POP connection and authentication with APOP