blob: e512ed91c4e28f619d359a9cfb41ba42e12e9246 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from flask_mail import Mail, Message
mail = None
def init_mail(webapp):
global mail
mail = Mail(webapp)
def send_message(recipients, subject, attachments, body):
"""
attachments is a list of tuples (filename, data)
libmagic is used to guess the mimetype
"""
msg = Message(subject, recipients=recipients)
msg.body = body
for filename, mimetype, data in attachments:
msg.attach(filename=filename, content_type=mimetype, data=data)
mail.send(msg)
|