tasks.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:xiaodi 作者: shenaishiren 项目源码 文件源码
def run(self, nickname=None, content=None, image=None):

        text = content + "<br>" + "<img src={image} />".format(image=image) \
                if image is not None else content
        msg = MIMEText(text, _subtype="html", _charset="utf-8")
        msg["Subject"] = "????"
        msg["From"] = nickname + "<" + MAIL_SENDER + ">"
        msg["To"] = ",".join(MAIL_RECEIVER_LIST)

        try:
            server = smtplib.SMTP()
            server.connect(MAIL_HOST)
            server.starttls()
            server.login(MAIL_SENDER, MAIL_PASSWORD)
            server.sendmail(MAIL_SENDER, MAIL_RECEIVER_LIST, msg.as_string())
            server.close()
        except Exception as e:
            LOG.error('send mail failed with error: %s' % str(e))
            return False
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号