diff options
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/mx/alias_resolver.py | 4 | ||||
-rw-r--r-- | src/leap/mx/check_recipient_access.py | 26 | ||||
-rw-r--r-- | src/leap/mx/mail_receiver.py | 4 |
3 files changed, 11 insertions, 23 deletions
diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py index 8155ff9..3f93f0d 100644 --- a/src/leap/mx/alias_resolver.py +++ b/src/leap/mx/alias_resolver.py @@ -53,6 +53,10 @@ class AliasResolverFactory(postfix.PostfixTCPMapDeferringDictServerFactory): orig_key = key try: logger.debug("Processing key: %s" % (key,)) + if key.find("@") == -1: + logger.debug("Ignoring key since it's not an email address") + return None + key = key.split("@")[0] key = key.split("+")[0] logger.debug("Final key to query: %s" % (key,)) diff --git a/src/leap/mx/check_recipient_access.py b/src/leap/mx/check_recipient_access.py index 8d03297..3ea6e91 100644 --- a/src/leap/mx/check_recipient_access.py +++ b/src/leap/mx/check_recipient_access.py @@ -22,11 +22,9 @@ Classes for resolving postfix recipient access import logging -try: - from twisted.protocols import postfix -except ImportError: - print "This software requires Twisted. Please see the README file" - print "for instructions on getting required dependencies." +from twisted.protocols import postfix + +from leap.mx.alias_resolver import AliasResolverFactory logger = logging.getLogger(__name__) @@ -39,21 +37,5 @@ class CheckRecipientAccess(postfix.PostfixTCPMapServer): self.sendCode(200) -class CheckRecipientAccessFactory(postfix.PostfixTCPMapDeferringDictServerFactory): - +class CheckRecipientAccessFactory(AliasResolverFactory): protocol = CheckRecipientAccess - - def __init__(self, couchdb, *args, **kwargs): - postfix.PostfixTCPMapDeferringDictServerFactory.__init__(self, *args, **kwargs) - self._cdb = couchdb - - def get(self, key): - orig_key = key - try: - key = key.split("@")[0] - key = key.split("+")[0] - except Exception as e: - key = orig_key - logger.exception("%s" % (e,)) - d = self._cdb.queryByLoginOrAlias(key) - return d diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py index ae32f25..9006471 100644 --- a/src/leap/mx/mail_receiver.py +++ b/src/leap/mx/mail_receiver.py @@ -105,7 +105,9 @@ def _process_incoming_email(users_db, mail_couchdb_url_prefix, self, filepath, m with filepath.open("r") as f: mail_data = f.read() mail = message_from_string(mail_data) - owner = mail["Delivered-To"] + owner = mail["To"] + if owner is None: # default to Delivered-To + owner = mail["Delivered-To"] owner = owner.split("@")[0] owner = owner.split("+")[0] logger.debug("Mail owner: %s" % (owner,)) |