How to attach files in email message in Flask?
I used flask_mail
library and achieved it. Firstly I saved images then attached them to my mail and lastly removed them from my directory.
for image in request.files.getlist('images'): image.save(image.filename) extension = image.filename.split('.')[-1] with app.open_resource(image.filename) as fp: msg.attach(image.filename,'image/' +extension, fp.read()) os.remove(image.filename)