• 【selenium+Python unittest】之发送带中文附件的邮箱


    完整原码如下:

    import smtplib
    from email.mime.text import MIMEText
    #from email.header import Header
    from email.mime.multipart import MIMEMultipart
    
    
    smtpserver = 'smtp.126.com'
    usersend = 'XXX@126.com'
    password = 'XXX'
    recevier = 'XXX@qq.com'
    
    subject = '坦克世界一览'
    
    #发送的附件C:UsersXXXDesktop坦克世界一览.txt
    sendfile = open('C:\Users\XXX\Desktop\坦克世界一览.txt','rb').read()
    att = MIMEText(sendfile,'base64','utf-8')
    att['Content-Type'] = 'application/octet-stream'
    att.add_header('Content-Disposition', 'attachment',filename=('gb2312', '', "坦克世界一览.txt"))
    
    msg = MIMEMultipart('related')
    msg.attach(att)
    msg['Subject'] = subject
    msg['From'] = usersend
    msg['To'] = recevier
    
    smtp = smtplib.SMTP()
    smtp.connect(smtpserver)
    smtp.login(usersend,password)
    smtp.sendmail(usersend,recevier,msg.as_string())
    smtp.quit()
  • 相关阅读:
    css半透明边框
    css脱离文档流
    margin负值的作用
    浅谈BFC
    css多列布局
    css布局--水平垂直居中
    css布局--垂直居中
    css布局--水平居中
    题解-APIO2019奇怪装置
    题解-AtCoder ARC-078F Mole and Abandoned Mine
  • 原文地址:https://www.cnblogs.com/Owen-ET/p/8409789.html
Copyright © 2020-2023  润新知