diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py index 93b8328..c7a8a92 100644 --- a/pagure/lib/notify.py +++ b/pagure/lib/notify.py @@ -232,6 +232,8 @@ def send_email(text, subject, to_mail, # Send the message via our own SMTP server, but don't include the # envelope header. + if isinstance(mailto, unicode): + mailto = mailto.encode('utf-8') msg['To'] = mailto salt = pagure.APP.config.get('SALT_EMAIL') if isinstance(mailto, unicode): diff --git a/tests/test_pagure_lib_notify.py b/tests/test_pagure_lib_notify.py index 124a311..855ac01 100644 --- a/tests/test_pagure_lib_notify.py +++ b/tests/test_pagure_lib_notify.py @@ -205,6 +205,17 @@ RW1haWwgY29udGVudA== ''' self.assertEqual(email.as_string(), exp) + email = pagure.lib.notify.send_email( + 'Email content', + 'Email “Subject“', + u'foo@bar.com,zöé@foo.net', + mail_id='test-pull-request-2edbf96ebe644f4bb31b94605e-1@pagure', + in_reply_to='test-pull-request-2edbf96ebe644f4bb31b94605e@pagure', + project_name='namespace/project', + user_from='Zöé', + ) + self.assertEqual(email.as_string(), exp) + if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase(PagureLibNotifytests)