emails.py 文件源码

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

项目:do-portal 作者: certeu 项目源码 文件源码
def send_email(sender, recipients, subject, text_body, html_body=None,
               attach=None):
    msg = Message(subject, reply_to=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body
    if attach:
        mimes = MimeTypes()
        for file in attach:
            path_ = os.path.join(current_app.config['APP_UPLOADS'], file)
            with current_app.open_resource(path_) as fp:
                mime = mimes.guess_type(fp.name)
                msg.attach(file, mime[0], fp.read())
    mail.send(msg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号