diff options
-rw-r--r-- | alot/mail/envelope.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/alot/mail/envelope.py b/alot/mail/envelope.py index 4d388aac..ad5f2ee4 100644 --- a/alot/mail/envelope.py +++ b/alot/mail/envelope.py @@ -221,6 +221,8 @@ class Envelope: ctype = helper.guess_mimetype(data) + params = [] + # accept only valid utf-8 as text attachments if ctype.partition('/')[0] == 'text': try: @@ -228,11 +230,13 @@ class Envelope: except UnicodeDecodeError as e: raise ValueError('Attachment is not valid UTF-8') from e + params.append(('charset', 'utf-8')) + # Set the filename parameter if not filename: filename = os.path.basename(path) - attachment = Attachment(data, ctype, filename, (('charset', 'utf-8'))) + attachment = Attachment(data, ctype, filename, tuple(params)) self.attach(attachment) def attach(self, attachment): |