aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/utils/email.py
diff options
context:
space:
mode:
authorJ08nY2017-07-17 22:02:08 +0200
committerJ08nY2017-07-17 22:02:08 +0200
commitb44b55f4cc508c1576870f3ff4b03bf0dab5513e (patch)
treeb74813a3376c7d054b6fd76201b2ee667622dc27 /src/mailman_pgp/utils/email.py
parent631fc4425cd5cd7220747defdc3f7658d94d8a36 (diff)
downloadmailman-pgp-b44b55f4cc508c1576870f3ff4b03bf0dab5513e.tar.gz
mailman-pgp-b44b55f4cc508c1576870f3ff4b03bf0dab5513e.tar.zst
mailman-pgp-b44b55f4cc508c1576870f3ff4b03bf0dab5513e.zip
Diffstat (limited to 'src/mailman_pgp/utils/email.py')
-rw-r--r--src/mailman_pgp/utils/email.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mailman_pgp/utils/email.py b/src/mailman_pgp/utils/email.py
index 4541313..80cf83f 100644
--- a/src/mailman_pgp/utils/email.py
+++ b/src/mailman_pgp/utils/email.py
@@ -16,6 +16,8 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
""""""
+from email.utils import parseaddr
+
from public import public
@@ -36,3 +38,12 @@ def copy_headers(from_msg, to_msg, overwrite=False):
to_msg[key] = value
if to_msg.get_unixfrom() is None:
to_msg.set_unixfrom(from_msg.get_unixfrom())
+
+
+@public
+def get_email(msg):
+ display_name, email = parseaddr(msg['from'])
+ # Address could be None or the empty string.
+ if not email:
+ email = msg.sender
+ return email