def mail():
    ret = True
    try:
        cur_time = time.strftime('%d/%m/%Y')
        msgRoot = MIMEMultipart('related')
        msgRoot['From'] = Header('PKU-AutoSubmit', 'utf-8')
        msgRoot['To'] = Header('student', 'utf-8')
        subject = (cur_time + ' 报备成功!')
        msgRoot['Subject'] = Header(subject, 'utf-8')
        msgAlternative = MIMEMultipart('alternative')
        msgRoot.attach(msgAlternative)
        mail_msg = '\n        <p>自动报备成功！</p>\n        <p>截图：</p>\n        <p><img src="cid:image1"></p>\n        '
        msgAlternative.attach(MIMEText(mail_msg, 'html', 'utf-8'))
        fp = open('result.png', 'rb')
        msgImage = MIMEImage(fp.read())
        fp.close()
        msgImage.add_header('Content-ID', '<image1>')
        msgRoot.attach(msgImage)
        server = smtplib.SMTP_SSL('smtp.qq.com', 465)
        server.login(my_sender, my_pass)
        server.sendmail(my_sender, [my_user], msgRoot.as_string())
        server.quit()
    except Exception:
        ret = False
    return ret
def mail():
    ret = True
    try:
        cur_time = time.strftime('%d/%m/%Y')
        msgRoot = MIMEMultipart('related')
        msgRoot['From'] = Header('PKU-AutoSubmit', 'utf-8')
        msgRoot['To'] = Header('student', 'utf-8')
        subject = (cur_time + ' 报备成功!')
        msgRoot['Subject'] = Header(subject, 'utf-8')
        msgAlternative = MIMEMultipart('alternative')
        msgRoot.attach(msgAlternative)
        mail_msg = '\n        <p>自动报备成功！</p>\n        <p>截图：</p>\n        <p><img src="cid:image1"></p>\n        '
        msgAlternative.attach(MIMEText(mail_msg, 'html', 'utf-8'))
        fp = open('result.png', 'rb')
        msgImage = MIMEImage(fp.read())
        fp.close()
        msgImage.add_header('Content-ID', '<image1>')
        msgRoot.attach(msgImage)
        server = smtplib.SMTP_SSL('smtp.qq.com', 465)
        server.login(my_sender, my_pass)
        server.sendmail(my_sender, [my_user], msgRoot.as_string())
        server.quit()
    except Exception:
        ret = False
    return ret