曾经在python 2.4 下写过的而一个发送邮件的类

在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()


除非申明,文章均为一号门原创,转载请注明本文地址,谢谢!
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: python
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.