diff options
| author | J08nY | 2017-07-17 22:02:08 +0200 |
|---|---|---|
| committer | J08nY | 2017-07-17 22:02:08 +0200 |
| commit | b44b55f4cc508c1576870f3ff4b03bf0dab5513e (patch) | |
| tree | b74813a3376c7d054b6fd76201b2ee667622dc27 /src/mailman_pgp/utils/email.py | |
| parent | 631fc4425cd5cd7220747defdc3f7658d94d8a36 (diff) | |
| download | mailman-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.py | 11 |
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 |
