# !/usr/bin/python
import sys,string
import poplib, email
def getMail(host, user, passwd, deletion = 0):
pop3 = poplib.POP3(host)
pop3.user(user)
pop3.pass_(passwd)
try :
num = len(pop3.list()[1])
except:
print "connection error with pop3.."
sys.exit()
print user, "has", num, "messages"
format = "%-5s %-40s %s"
if num > 0:
if deletion:
print "Deleting", num, "messages",
for i in range(1, num+1):
pop3.dele(i)
print ".",
print " done."
else:
print format % ("Num", "From", "Subject")
for i in range(1, num+1):
str = string.join(pop3.top(i, 1)[1], "\n")
msg = email.message_from_string(str)
print format % (i, msg["From"], msg["Subject"])
pop3.quit()
# the program starts heree...
if __name__ =='__main__':
host = "" # ur host name
user = "" # ur username
passwd = "" # ur password
getMail(host,user,passwd) # get with my function