def mail_submit(): msg = MIMEMultipart() msg = Message('Hello world!', sender=app.config['MAIL_USERNAME'], recipients=['*****@*****.**', '*****@*****.**']) msg.body = "Hello Flask message sent from Flask-Mail" files = ['static/download.jpg'] for f in files: part = MIMEBase('application', "octet-stream") part.set_payload(open(f, "rb").read()) encoders.encode_base64(part) part.add_header( 'Content-Disposition', 'attachment; filename="{0}"'.format(os.path.basename(f))) msg.attach(part) mail.send(msg) return "Sent"