CSDN一篇文章下载

查看 53|回复 2
作者:Eks6666   
CSDN文章地址:https://blog.csdn.net/xiaoyaGrace/article/details/103489193

一篇文章, 地址

a3131311026   

[Python] 纯文本查看 复制代码import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header

# 配置邮箱服务器
smtpserver = "smtp.163.com"

# 用户/密码
user = "[email protected]"
password = "123456"

# 发送者邮箱
sender = "[email protected]"

# 接收者邮箱
receiver = [ "[email protected]" , "[email protected]" ]

# 邮件主题
subject = "Python-email3"

msg = MIMEMultipart()
# 多人接收邮件,直接显示下面账号的名字
msg[ 'From' ] = "[email protected]"
msg[ 'To' ] = "[email protected]"
msg[ "cc" ] = "[email protected]"
msg[ "Subject" ] = Header(subject, "utf-8" )
# 添加正文
msg.attach(MIMEText( '你好!' , "html" , "utf-8" ))

# 添加附件
sendFile = open ( "./测试报告.html" , 'rb' ).read()
att = MIMEText(sendFile, "base64" , "utf-8" )
att.add_header( "Content-Type" , "application/octet-stream" )
att.add_header( "Content-Disposition" , "attachment" , filename = "测试报告.html" )
msg.attach(att)

if __name__ = = '__main__' :
     smtp = smtplib.SMTP()
     smtp.connect(smtpserver, 25 )
     smtp.login(user, password)
     smtp.sendmail(sender, receiver, msg.as_string())
     smtp.quit()
                        
Joseph_TF   

链接:https://pan.baidu.com/s/1qiChpy9X1trZnHKvjGlFbw
提取码:dgoi
您需要登录后才可以回帖 登录 | 立即注册

返回顶部