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)
评论列表
文章目录