diff --git a/bin/mailbox2matrix b/bin/mailbox2matrix index 32aee32..f51b6a2 100755 --- a/bin/mailbox2matrix +++ b/bin/mailbox2matrix @@ -3,13 +3,18 @@ import asyncio import email import pathlib -from os import path, listdir import sys import logging + +from os import path, listdir +from email.header import decode_header, make_header from nio import (AsyncClient, Api, ClientConfig, RoomSendError) from inotify_simple import INotify, flags +def decode(header): + return make_hader(decode_header(header)) + class Client(AsyncClient): def send_message(self, From, Subject): @@ -18,7 +23,7 @@ class Client(AsyncClient): message_type="m.room.message", content={ "msgtype": "m.text", - "body": "From:\t%s\nSubject:\t%s" % (From, Subject) + "body": "From:\t%s\nSubject:\t%s" % (decode(From), decode(Subject)) } )