Retrieving Email from a POP3 Server : SMTP : Network PYTHON TUTORIALS


PYTHON TUTORIALS » Network » SMTP »

 

Retrieving Email from a POP3 Server


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()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Network
» SMTP