直播app源码,验证方式选择邮箱验证时,自动给输入好的邮箱发送验证码

直播app源码,验证方式选择邮箱验证时,自动给输入好的邮箱发送验证码实现的相关代码

 

import smtplib
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
 
#发送多种类型的邮件
from email.mime.multipart import MIMEMultipart
 
from PIL import ImageGrab
im = ImageGrab.grab()
im.save('s'+'.png')
 
msg_from = '666666666@qq.com'  # 发送方邮箱
passwd = '66666666666666'
 
to= ['555555555@qq.com'] #接受方邮箱
 
#设置邮件内容
#MIMEMultipart类可以放任何内容
msg = MIMEMultipart()
conntent="这个是字符串"
#把内容加进去
#msg.attach(MIMEText(conntent,'plain','utf-8'))
 
# 二进制读取图片
image_data=open('1.jpg','rb')
# 设置读取获取的二进制数据
message_image = MIMEImage(image_data.read())
# 关闭刚才打开的文件
image_data.close()
# 添加图片文件到邮件信息当中去
#msg.attach(message_image)
 
 
#添加附件
att1=MIMEText(open('result.xlsx','rb').read(),'base64','utf-8')  #打开附件
att1['Content-Type']='application/octet-stream'   #设置类型是流媒体格式
att1['Content-Disposition']='attachment;filename=result.xlsx'  #设置描述信息
 
att2=MIMEText(open('1.jpg','rb').read(),'base64','utf-8')
att2['Content-Type']='application/octet-stream'   #设置类型是流媒体格式
att2['Content-Disposition']='attachment;filename=1.jpg'  #设置描述信息
 
msg.attach(att1)   #加入到邮件中
msg.attach(att2)
 
#设置邮件主题
msg['Subject']="这个是邮件主题"
 
#发送方信息
msg['From']=msg_from
 
#开始发送
 
#通过SSL方式发送,服务器地址和端口
s = smtplib.SMTP_SSL("smtp.qq.com", 465)
# 登录邮箱
s.login(msg_from, passwd)
#开始发送
s.sendmail(msg_from,to,msg.as_string())
print("邮件发送成功")

以上就是直播app源码,验证方式选择邮箱验证时,自动给输入好的邮箱发送验证码实现的相关代码, 更多内容欢迎关注之后的文章

 

posted @ 2022-02-15 14:20  云豹科技-苏凌霄  阅读(165)  评论(0)    收藏  举报