Retrieving Email from a POP3 Server : SMTP « Network « Python Tutorial






import poplib
import getpass

mServer = poplib.POP3('mail.sfcn.org')

mServer.user(getpass.getuser())
mServer.pass_(getpass.getpass())

numMessages = len(mServer.list()[1])

print "You have %d messages." % (numMessages)

for mList in range(numMessages) :
    for msg in mServer.retr(mList+1)[1]:
        if msg.startswith('Subject'):
            print msg
            break

mServer.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