python发QQ邮件
2022/3/8 20:15:00
本文主要是介绍python发QQ邮件,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
python发qq邮件相对比较简单,网上教程一大把;固定套路,后面封装看自己怎么方便可以怎样进行封装;原版代码如下:
"""
# -*- coding : utf-8 -*- # @Time : 2021/3/28 18:54 # @Author : gan """
#导入三个固定短信邮箱模块
import smtplib from email.mime.text import MIMEText from email.header import Header mail_host = "smtp.qq.com" mail_user = "111111@qq.com" #发送方邮箱 mail_pwd = "abcdefghijklmno" #发送方邮箱的授权码 sender = "1111@qq.com" receivers = ["11111@qq.com","22222@qq.com"] #多位接收人 message = MIMEText("测试结果正文","plain","utf-8") message["From"] = Header("自动化测试小组","utf-8") message["To"] = Header("开发小组","utf-8") subject = "测试结果邮件" message['Subject'] = Header(subject,"utf-8") try: smtpObj = smtplib.SMTP() smtpObj.connect(mail_host,25) smtpObj.login(mail_user,mail_pwd) smtpObj.sendmail(sender,receivers,message.as_string()) print("邮件发送成功") except smtplib.SMTPException: print("无法发送")
这篇关于python发QQ邮件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南
- 2024-11-16`PyMuPDF4LLM`:提取PDF数据的神器
- 2024-11-16四种数据科学Web界面框架快速对比:Rio、Reflex、Streamlit和Plotly Dash
- 2024-11-14获取参数学习:Python编程入门教程
- 2024-11-14Python编程基础入门