惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 木子东晓东

当androidStudio下载gradle出错时,切换到国内镜像的方法 DevEco Studio 调用hdc的方法 运行Flutter 真机运行安卓报错 将字符串数字转换为薪资类型10000转换为10,000 - 木子东晓东 使用magicAPI对接python 文件,上传参数获取不到回参问题 py集成宝塔,flask已加入模块,无法实现自动发送邮件功能 谷歌浏览器降级的方法-及chromedriver 下载文件 若依框架导入阿里OSS报错问题解决方案 解决若依框架与tailwindcss 样式冲突问题 若依框架前期启动工作 运行若依时报错 MAC 使用docker 启动宝塔 MAC flutter初步学习 2 iOS 审核被拒,日志中找不到苹果返回的creashlog的解决办法 flutter学习之添加第三方应用 MAC flutter初步学习 python Django 连接数据库失败的解决方法 Python之学习菜鸟教程踩的坑 Python学习之环境搭建
使用python 实现自动发送邮件功能,并上传到宝塔
木子东晓东 · 2024-08-14 · via 博客园 - 木子东晓东

def send_qq_mail(subject, content, receiver):

sender = "你的邮箱"

smtpserver = "smtp.qq.com" #使用的是qq邮箱

port = 465 # 端口号

user = '你的邮箱'

password = '授权码' # 请确保这是正确的密码或授权码

《具体去查询qq邮箱授权码》

msg = MIMEText(content, 'plain', 'utf-8') # 发送的文本信息

msg['Subject'] = Header(subject, 'utf-8')

msg['From'] = sender # 应该使用 sender 变量,而不是 user(尽管在这里它们是相同的)

msg['To'] = receiver

try:

# smtp = smtplib.SMTP()

# 在实例化时传入服务器地址和端口号

smtp = smtplib.SMTP_SSL(smtpserver, port)

smtp.login(user, password)

# 注意 receiver 应该是一个列表

smtp.sendmail(sender, [receiver], msg.as_string())

smtp.quit() # 显式关闭连接是一个好习惯

except smtplib.SMTPException:

print("Error: 无法发送邮件")

return ("Error: 无法发送邮件")

 注意事项

1、放行端口号

465端口。不然发送邮件无法连接-宝塔、阿里云

2、不要使用这个方法

# smtp = smtplib.SMTP()

这个方法不加密,会被平台毙掉。无法访问

3、有问题多去查看日志,用gpt读一下日志的问题进行修改