实例1
#coding:utf-8
import sys
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
def sendEmail(msgTo, content, type):
#(attachment,html) = content
msg = MIMEMultipart()
msg['Subject'] = type
msg['From'] = '1067302838@qq.com'
msg['To'] = msgTo
att = MIMEText(content,'plain', 'utf-8')
msg.attach(att)
try:
smtp = smtplib.SMTP()
smtp.connect('smtp.qq.com', 25)
smtp.login(msg['From'], 'password')
smtp.sendmail(msg['From'], msg['To'].split(','), msg.as_string())
except Exception,e:
print e
if __name__ == '__main__':
ToUser='1067302838@qq.com'
sendEmail(ToUser,"qa", u'主题')