使用python的smtp模块发送邮件
来源:互联网 发布:社工库数据下载 编辑:程序博客网 时间:2024/05/16 01:26
使用Python的smtp模块,可以十分方便的编写自己的smtp客户端,来发送邮件。现在发现,不能使用腾讯的smtp服务器去法送,但是可以使用163的smtp服务器去发送邮件。
直接上代码吧
#!/usr/bin/env python''' a simple smtp client'''import smtplibfrom email.mime.text import MIMETextdef sendMail(user,pwd,to,subject,text): msg=MIMEText(text) msg['From']=user msg['To']=to msg['Subject']=subject try: #smtpServer=smtplib.SMTP('smtp.qq.com',587)#Configure 1 smtpServer=smtplib.SMTP('smtp.163.com',25)#Configure 2 print "[+] Connecting To Mail Server" smtpServer.ehlo() print "[+] Starting Encrypted Session" smtpServer.starttls() smtpServer.ehlo() print "[+] Logging Into Mail Server" smtpServer.login(user,pwd) print "[+] Logging successfully" print "[+] Sendding Mail" smtpServer.sendmail(user,to,msg.as_string()) smtpServer.close() print "[+] Mail send Successfully" except: print "[+] Mail send failed"def main(): 'Configure 1: from qq mail to 163 mail' #user=""#type in your own qq email account #pwd=""#type in your own qq email pwd #to="""#type in your own 163 email account 'Configure 2: from 163 mail to qq mail' user=""#type in your own 163 email account pwd=""#type in your own 163 email pwd to=""#type in your own qq email account subject="test my client" text="test test test" sendMail(user,pwd,to,subject,text)if __name__=="__main__": main()填写自己的邮件地址和目的邮件地址,就可以轻松使用自己的smtp客户端了。
0 0
- 使用python的smtp模块发送邮件
- python使用smtp发送邮件
- Python使用SMTP发送邮件
- Python -- 使用SMTP发送邮件
- Python 使用smtp发送邮件
- Python使用SMTP发送邮件
- python的smtp邮件发送
- Python(2.7.x)使用SMTP发送邮件的简单示例
- python使用smtp库发送邮件
- python 使用smtp发送群邮件
- Python使用SMTP自动发送邮件
- Python使用smtp协议发送邮件
- python smtp发送邮件
- python smtp发送邮件
- Python SMTP发送邮件
- Python SMTP发送邮件
- python smtp 发送邮件
- Python SMTP发送邮件
- 3个著名加密算法(MD5、RSA、DES)的解析
- qt 5.0中HeaderView的setResiziMode无法使用的问题
- MediaPlayer 和 AVPlayer
- 下载android4.4.2源码全过程(附已下载的源码)
- WinServer2008 R2下部署SQL 2008 群集(Part2)
- 使用python的smtp模块发送邮件
- maven install与maven build的区别
- Android高手进阶教程(一)-------Android常用名令集锦(图文并茂)!
- 页面导入导出excel 相关
- Spring Quartz动态配置时间
- 如何使用maven构建项目
- SSH轻量级框架的理解
- Cocos2d-JS加速度计与加速度事件
- 计算机网络网络层