mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
email mirror: make being one of many recipients okay.
Previously the email gateway had to be the only address in a recipient field or we'd mis-parse the recipient. This commit also makes the mirror correctly handle addresses of the form "Jessica McKellar <jesstess@zulip.com>". (imported from commit 7435f2b59b8f47dc599cc869f64597a730af7d12)
This commit is contained in:
@@ -18,6 +18,7 @@ Run this management command out of a cron job.
|
||||
import email
|
||||
from os import path
|
||||
from email.header import decode_header
|
||||
from email.utils import getaddresses
|
||||
import logging
|
||||
import re
|
||||
import sys
|
||||
@@ -159,9 +160,11 @@ def delete(result, proto):
|
||||
def find_emailgateway_recipient(message):
|
||||
# We can't use Delivered-To; that is emailgateway@zulip.com.
|
||||
for header in ("To", "Cc", "Bcc"):
|
||||
recipient = message.get(header)
|
||||
if recipient and recipient.lower().endswith("@streams.zulip.com"):
|
||||
return recipient
|
||||
recipients = getaddresses(message.get_all(header, []))
|
||||
for recipient_name, recipient_email in recipients:
|
||||
if recipient_email.lower().endswith("@streams.zulip.com"):
|
||||
return recipient_email
|
||||
|
||||
raise ZulipEmailForwardError("Missing recipient @streams.zulip.com")
|
||||
|
||||
def fetch(result, proto, mailboxes):
|
||||
|
||||
Reference in New Issue
Block a user