diff options
-rw-r--r-- | mail2news.py | 7 | ||||
-rw-r--r-- | news2mail.py | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/mail2news.py b/mail2news.py index ced7897..6a7aaff 100644 --- a/mail2news.py +++ b/mail2news.py @@ -17,6 +17,7 @@ class mail2news is hopefully conform to rfc850. import io from collections import OrderedDict import email +import email.policy import logging import nntplib import os @@ -65,14 +66,14 @@ class mail2news(object): msg[header] = value.strip() def __readfile(self, opt): - message = email.message_from_binary_file(sys.stdin.buffer) + message = email.message_from_file(sys.stdin, policy=email.policy.default) if (len(message) == 0) \ and message.get_payload().startswith('/'): msg_file_name = message.get_payload().strip() del message - with open(msg_file_name, 'rb') as msg_file: - message = email.message_from_binary_file(msg_file) + with open(msg_file_name, 'r') as msg_file: + message = email.message_from_file(msg_file, policy=email.policy.default) # introduce nntpheads self.__add_header('Newsgroups', opt.newsgroup, message) diff --git a/news2mail.py b/news2mail.py index 624290f..a92c7e5 100644 --- a/news2mail.py +++ b/news2mail.py @@ -26,6 +26,7 @@ from __future__ import absolute_import from __future__ import print_function from collections import OrderedDict import email +import email.policy import smtplib from socket import gethostbyaddr, gethostname import sys @@ -52,7 +53,8 @@ class news2mail(object): self.heads_dict = {} self.article, self.headers, self.body = [], [], [] - self.message = self.__addheads(email.message_from_binary_file(sys.stdin.buffer)) + self.message = self.__addheads( + email.message_from_file(sys.stdin, policy=email.policy.default)) def __addheads(self, msg): """add new header like X-Gateway: Received: |