flask-mail icon indicating copy to clipboard operation
flask-mail copied to clipboard

Unicode pt-BR

Open engmsilva opened this issue 5 years ago • 2 comments

Is there a simple way to configure flask-email to accept unicode pt-BR?

This is flask-mail configuration:

msg = Message(
        subject,
        sender=mail_settings.get("MAIL_USERNAME"),
        recipients=[email],
        body='Olá como vai você'.encode('utf-8'),
        charset='utf-8'
        ) 

I get the following error:

 msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode character '\xe1' in position 322: ordinal not in range(128)

Strangely the subject accepts unicode

engmsilva avatar Dec 14 '19 23:12 engmsilva

Well you are passing utf-8 bytes and not unicode for the body right now...

ThiefMaster avatar Apr 14 '20 07:04 ThiefMaster

which parameter to configure to pass the unicode?

engmsilva avatar Apr 14 '20 09:04 engmsilva

A body with unicode characters seems to be supported correctly, no .encode call needed.

davidism avatar May 23 '24 17:05 davidism