python实现smtp发送邮件类-直接调用就好
来源:互联网 发布:西方建筑欣赏知乎 编辑:程序博客网 时间:2024/06/06 16:49
python实现smtp发送邮件类
使用方法
#使用方法Sendmail('stmp服务器', '邮箱', '密码', 发送的邮箱用list格式,可多个发送)p = Sendmail('smtp.minshengec.cn', 'wangqi@minshengec.cn', 'xxoofor you', ['wangqi@minshengec.cn'])#setMailInfo('标题', '内容')p.setMailInfo('dsadsa', 'xxoo')#最后运行run方法p.run()
#!/usr/bin/env python# -*- coding: gbk -*-#导入smtplib和MIMETextimport smtplibfrom email.mime.text import MIMETextclass Sendmail(object): def __init__(self, mailHost, mailUser, mailPwd): self.mailHost = mailHost; self.mailUser = mailUser; self.mailPwd = mailPwd; self.sendList = [];#function subject->title def setMailInfo(self, sendList,subject, content): self.sendList = sendList self.content = content; self.subject = subject; self.msg = MIMEText(self.content) self.msg['From'] = self.mailUser self.msg['Subject'] = self.subject self.msg['To'] = ";".join(self.sendList) def run(self): try: self.send = smtplib.SMTP() self.send.connect(self.mailHost) self.send.login(self.mailUser, self.mailPwd) self.send.sendmail(self.mailUser, self.sendList, self.msg.as_string()) print '[*]-----send mail---to' + str(self.sendList) + 'success-----[*]' except smtplib.SMTPException as e: print e#p = Sendmail('smtp.minshengec.cn', 'wangqi@minshengec.cn', 'xxoo for you')#p.setMailInfo(['wangqi@minshengec.cn'], 'dsadsaqqq', 'xxodsado')#p.run()
0 0
- python实现smtp发送邮件类-直接调用就好
- 用Python实现SMTP邮件发送
- python smtp发送邮件
- python smtp发送邮件
- Python SMTP发送邮件
- Python SMTP发送邮件
- python smtp 发送邮件
- Python SMTP发送邮件
- Python SMTP发送邮件
- python SMTP发送邮件
- Python SMTP发送邮件
- Python SMTP发送邮件
- Python SMTP发送邮件
- Python SMTP发送邮件
- smtp 发送邮件类
- Python发送邮件(Email SMTP)
- python使用smtp发送邮件
- python下smtp发送邮件
- 自定组合控件的过程
- 栈与递归实现Hanoi塔问题
- MMD_2c_FrequentItemsets
- 一个Java对象到底占用多大内存
- git将本地仓库上传到远程仓库
- python实现smtp发送邮件类-直接调用就好
- 一只简单的网络爬虫(基于linux C/C++)————支持动态模块加载
- 计算器类app应用体验
- linux服务器病毒
- myeclipse中tomcat 报异常总结
- 人机交互
- Base64以及Md5的使用
- Handlebars基本使用
- Hadoop的内存配置