Improve email encoding
All checks were successful
docker-image / docker (push) Successful in 3m28s

This commit is contained in:
Stefan Bethke 2024-06-07 14:40:54 +02:00
parent e0439dc667
commit cecad168d0

View file

@ -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)