mattupstate/flask-mail — pull request #50 by dmr (2013-10-09 17:35:30+00:00)
Title: Insert force_text(subject)?

I have a weird error with flask-mail in combination with flask-babel:

I translate my subject header with lazy_gettext() and when I send a mail I get an error.

I tracked the error down to speaklater

from flask_mail import Message
from speaklater import make_lazy_string
k = dict(sender='f@example.com')

msg = Message(subject=u"sübject", **k)
assert '=?utf-8?q?s=C3=BCbject?=' in msg.as_string()

msg = Message(subject=make_lazy_string(lambda a: a, u"sübject"), **k)
assert '=?utf-8?q?s=C3=BCbject?=' in msg.as_string()

Replacing

msg['Subject'] = self.subject

with

msg['Subject'] = force_text(self.subject)

would solve my issue.

Although this is not directly a flask-mail issue I think to have a lazy_gettext string as a subject is pretty much the standard use case.

Can this be integrated into flask-mail?