aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/utils/email.py
diff options
context:
space:
mode:
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