首页 > 代码库 > Python实现QQ邮箱发送
Python实现QQ邮箱发送
具体参考代码:
#!/usr/bin/env python # encoding: utf-8 import smtplib from email.mime.text import MIMEText class MyEmail: def __init__(self, subject, body): self.subject = subject self.body = body self.host = ‘smtp.qq.com‘ self.port = 465 self.sender = ‘sender@qq.com‘ self.pwd = ‘password‘ self.receiver = ‘receiver@qq.com‘ def send_email(self): msg = MIMEText(self.body, ‘plain‘, ‘utf-8‘) msg[‘subject‘] = self.subject msg[‘from‘] = self.sender msg[‘to‘] = self.receiver s = smtplib.SMTP_SSL(self.host, self.port) s.login(self.sender, self.pwd) s.sendmail(self.sender, self.receiver, msg.as_string()) if __name__ == ‘__main__‘: my_email = MyEmail(‘这是一封测试邮件‘, ‘这是一封测试邮件,请不要回复,谢谢‘) my_email.send_email()
本文出自 “许大树” 博客,谢绝转载!
Python实现QQ邮箱发送
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。