曾经在python 2.4 下写过的而一个发送邮件的类
By:Roy.LiuLast updated:2012-03-04
在python 2.4 下写过的一个发邮件的类
import smtplib from email.MIMEBase import MIMEBase from email.MIMEText import MIMEText from email.MIMEMultipart import MIMEMultipart import email import time import persistent class MyEmail: """this moudle is for send email lzs 2006.08.26""" def __init__(self,femail='summer@yihaomen.com',fpwd='xxxxxx',tmail='sunny3super@163.com',subject='hello',mybody='this letter is from yihaomen.com'): self.femail=femail self.fpwd=fpwd self.temail=tmail self.mybody=mybody self.subject=subject def SendEmail(self): my_body=self.mybody msg=MIMEMultipart() msg['From'] = self.femail msg['To'] = self.temail msg['Subject'] = self.subject msg['Reply-To'] = self.femail msg['Date'] = time.ctime(time.time()) msg['X-Priority'] = '''3''' msg['X-MSMail-Priority'] = '''Normal''' body=email.MIMEText.MIMEText(self.mybody,_subtype='html',_charset='gb2312') msg.attach(body) s = smtplib.SMTP('smtp.126.com') s.login(self.femail,self.fpwd) s.sendmail(self.femail,self.temail,msg.as_string()) s.close()
From:一号门
Previous:转载一个python基类,多态的文章
COMMENTS