diff --git a/hedgedoc-expire.py b/hedgedoc-expire.py index 857881c..fbcc805 100644 --- a/hedgedoc-expire.py +++ b/hedgedoc-expire.py @@ -229,10 +229,12 @@ class HedgedocExpire: The admin team for {self.config.url} - '''))) - md = MIMEBase('text', 'markdown') - md.add_header('Content-Disposition', f'attachment; filename={note["title"]}.md') - md.set_payload(note["content"].encode(encoding='utf-8')) + '''), 'plain', 'utf-8')) + md = MIMEText(note["content"], 'markdown', 'utf-8') + filename = note['title'].encode('ascii', 'ignore').decode('utf-8') + if len(filename) == 0: + filename = 'note' + md.add_header('Content-Disposition', f'attachment; filename={filename}.md') msg.attach(md) self.email_sender.send(msg)