博客
关于我
用Python单发/群发邮件
阅读量:91 次
发布时间:2019-02-26

本文共 520 字,大约阅读时间需要 1 分钟。

import smtplibfrom email.mime.text import MIMEText# 邮件配置smtp_server = 'smtp.163.com'smtp_port = 25from_email = 'email@163.com'auth_code = 'your_password'to_email = 'fuck0@qq.com'# SMTP客户端初始化smtp = smtplib.SMTP(smtp_server, smtp_port)smtp.login(from_email, auth_code)# 创建邮件对象msg = MIMEText('这是一个测试邮件')msg['Subject'] = '【测试邮件】'msg['From'] = from_emailmsg['To'] = to_email# 发送邮件smtp.sendmail(from_email, to_email, msg.as_string())smtp.close()

注:以上代码用于通过163邮箱发送测试邮件,确保配置信息(如邮箱地址和授权码)已正确填写。如果需要发送到多个收件人,可将to_email改为多个地址的列表形式。

转载地址:http://bzwu.baihongyu.com/

你可能感兴趣的文章
Net与Flex入门
查看>>
net包之IPConn
查看>>
NFinal学习笔记 02—NFinalBuild
查看>>
NFS共享文件系统搭建
查看>>
nfs复习
查看>>
NFS网络文件系统
查看>>
nft文件传输_利用remoting实现文件传输-.NET教程,远程及网络应用
查看>>
ng 指令的自定义、使用
查看>>
nginx + etcd 动态负载均衡实践(二)—— 组件安装
查看>>
nginx + etcd 动态负载均衡实践(四)—— 基于confd实现
查看>>
Nginx + Spring Boot 实现负载均衡
查看>>
Nginx + uWSGI + Flask + Vhost
查看>>
Nginx - Header详解
查看>>
Nginx Location配置总结
查看>>
Nginx upstream性能优化
查看>>
Nginx 中解决跨域问题
查看>>
Nginx 动静分离与负载均衡的实现
查看>>
Nginx 反向代理 MinIO 及 ruoyi-vue-pro 配置 MinIO 详解
查看>>
Nginx 反向代理解决跨域问题
查看>>
Nginx 反向代理配置去除前缀
查看>>