From 8a1f49a90686cba32edc78f8fa9189844a0dd596 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 5 Sep 2020 01:29:43 +0200 Subject: [PATCH] Open the source file in read non-binary mode in case of MIMEText --- platypush/plugins/mail/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/mail/__init__.py b/platypush/plugins/mail/__init__.py index c8641c7c..68681dcd 100644 --- a/platypush/plugins/mail/__init__.py +++ b/platypush/plugins/mail/__init__.py @@ -170,9 +170,12 @@ class MailOutPlugin(MailPlugin, ABC): args = {} if _type_class != MIMEText: + mode = 'rb' args['Name'] = os.path.basename(file) + else: + mode = 'r' - with open(file, 'rb') as f: + with open(file, mode) as f: return _type_class(f.read(), _subtype, **args) @classmethod