- module
#coding: utf-8
import smtplib
import os.path
from email.mime.text import MIMEText
class notifyByEmail:
def __init__(self, msgSubject, msgContent):
self.msgSubject = msgSubject
self.msgContent = msgContent
def sendEmail(self):
#msg = MIMEText(self.msgContent.encode('utf-8'), 'plain', 'utf-8')
#msg['Subject'] = Header(self.msgSubject,'utf-8')
msg = MIMEText(self.msgContent)
msg['Subject'] = self.msgSubject
s = smtplib.SMTP_SSL('smtp.fastmail.com:465')
s.login('123','123')
recvs = ['xxx.cn']
s.sendmail('xxx',recvs, msg.as_string())
print ','.join(recvs)
s.quit()
print "done"
- usage
falconmail.notifyByEmail("测试标题","测试一下下").sendEmail()
- 遗留问题
可恶的编码