一段简单的python邮件客户端发送代码

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#/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('username@126.com')
    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()