aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/utils
diff options
context:
space:
mode:
authorJ08nY2017-08-02 00:15:21 +0200
committerJ08nY2017-08-02 01:35:10 +0200
commitfa2b97fb2e6e75af8bfc0bc3620b1a37179bdedc (patch)
tree5dee4554ab4b99fb2dd9b93f8e43a4978ad0d469 /src/mailman_pgp/utils
parentdff7befbc5860f2f78f63ab694ef88d21a53771f (diff)
downloadmailman-pgp-fa2b97fb2e6e75af8bfc0bc3620b1a37179bdedc.tar.gz
mailman-pgp-fa2b97fb2e6e75af8bfc0bc3620b1a37179bdedc.tar.zst
mailman-pgp-fa2b97fb2e6e75af8bfc0bc3620b1a37179bdedc.zip
Diffstat (limited to 'src/mailman_pgp/utils')
-rw-r--r--src/mailman_pgp/utils/email.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mailman_pgp/utils/email.py b/src/mailman_pgp/utils/email.py
index a936458..9eff313 100644
--- a/src/mailman_pgp/utils/email.py
+++ b/src/mailman_pgp/utils/email.py
@@ -16,8 +16,10 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
""""""
+import copy
from email.utils import parseaddr
+from mailman.email.message import MultipartDigestMessage
from public import public
@@ -62,6 +64,24 @@ def overwrite_message(from_msg, to_msg):
@public
+def make_multipart(msg):
+ """
+
+ :param msg:
+ :type msg: email.message.Message
+ :return:
+ :rtype: email.message.MIMEMultipart|mailman.email.message.MultipartDigestMessage
+ """
+ if msg.is_multipart():
+ out = copy.deepcopy(msg)
+ else:
+ out = MultipartDigestMessage()
+ out.attach(msg)
+ copy_headers(msg, out)
+ return out
+
+
+@public
def get_email(msg):
display_name, email = parseaddr(msg['from'])
# Address could be None or the empty string.