3
Setting up flask and testing was quick and easy but sending attachments is very difficult if not impossible. Someone has a tip or example for sending attachments with Flask-Mail?
My code is like this:
mail = Mail(app)
MAIL_CONFIG = app.config
msg = Message(
assunto,
sender = (MAIL_CONFIG['MAIL_NAME'], MAIL_CONFIG['MAIL_USERNAME']),
reply_to = MAIL_CONFIG['MAIL_NAME'] + '<' + MAIL_CONFIG['MAIL_USERNAME'] + '>',
recipients = destinatarios
)
msg.body = texto
msg.html = mensagem
# arquivo = 'downloads/bbbb.txt'
# with app.open_resource(arquivo) as fp:
# msg.attach(arquivo, "text/plain", fp.read())
mail.send(msg)
If I blur the commented lines I have the following error:
Typeerror: normalize() argument 2 must be Unicode, not str
What you’ve tried so far?
– Miguel