diff options
| author | J08nY | 2017-08-02 00:15:21 +0200 |
|---|---|---|
| committer | J08nY | 2017-08-02 01:35:10 +0200 |
| commit | fa2b97fb2e6e75af8bfc0bc3620b1a37179bdedc (patch) | |
| tree | 5dee4554ab4b99fb2dd9b93f8e43a4978ad0d469 /src/mailman_pgp/utils/email.py | |
| parent | dff7befbc5860f2f78f63ab694ef88d21a53771f (diff) | |
| download | mailman-pgp-fa2b97fb2e6e75af8bfc0bc3620b1a37179bdedc.tar.gz mailman-pgp-fa2b97fb2e6e75af8bfc0bc3620b1a37179bdedc.tar.zst mailman-pgp-fa2b97fb2e6e75af8bfc0bc3620b1a37179bdedc.zip | |
Diffstat (limited to 'src/mailman_pgp/utils/email.py')
| -rw-r--r-- | src/mailman_pgp/utils/email.py | 20 |
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. |
