学习笔记,不喜勿喷~~
使用的python版本python3.3
脚本下载地址:http://download.csdn.net/detail/sushengmiyan/5967151
本文链接-转载请保留:http://blog.csdn.net/sushengmiyan/article/details/10037691
步骤1.新建文本文件,修改后缀名为.py文件名任意。比如EmailSender.py
里面是代码,如下:
import smtplib from email.mime.text import MIMEText from email.header import Header def SendEmail(fromAdd, toAdd, subject, attachfile, htmlText): strFrom = fromAdd; strTo = toAdd; msg =MIMEText(htmlText); msg['Content-Type'] = 'Text/HTML'; msg['Subject'] = Header(subject,'gb2312'); msg['To'] = strTo; msg['From'] = strFrom; smtp = smtplib.SMTP('smtp.qq.com'); smtp.login('1806007002@qq.com','12345678'); try: smtp.sendmail(strFrom,strTo,msg.as_string()); finally: smtp.close; if __name__ == "__main__": #主函数,脚本从这里开始执行,SendEmail是函数名称 SendEmail("1806007002@qq.com","1806007002@qq.com","","hello","hello world");
就这样就可以咯。具体的内容解释可以去下载我的脚本看吧`