#/usr/bin/python # -*- coding: utf-8 -*- import re import smtplib from poplib import POP3 from email.mime.text import MIMEText def sevname(username): pa = r'@(/w+)/.' sev = re.search(pa,username).group(1) return sev username = raw_input('email:') password = raw_input('password:') sev = sevname(username) SMTPSVR = 'smtp.' + sev + '.com' POP3SVR = 'pop.' + sev + '.com' SMTPSVR = 'smtp.126.com' POP3SVR = 'pop.126.com' def login(): p = POP3(POP3SVR) print POP3SVR p.user([email protected]') p.pass_('password') rsp,msg,siz = p.retr(p.stat()[0]) sep = msg.index('') print msg for line in msg: print line recvBody = msg[sep+1:] print recvBody for x in xrange(1,p.stat()[0]): rsp,msg,siz = p.retr(x) print msg p.quit() if __name__ == '__main__': login()
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8202.html