diff options
Diffstat (limited to 'alot/commands/thread.py')
-rw-r--r-- | alot/commands/thread.py | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py index a6380ac9..5d8a7939 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -72,30 +72,34 @@ def determine_sender(mail, action='reply'): # pick the most important account that has an address in candidates # and use that accounts realname and the address found here for account in my_accounts: - acc_addresses = [re.escape(str(a)) for a in account.get_addresses()] + acc_addresses = [ + re.escape(str(a)) for a in account.get_addresses()] if account.alias_regexp is not None: acc_addresses.append(account.alias_regexp) for alias in acc_addresses: regex = re.compile( u'^' + str(alias) + u'$', - flags=re.IGNORECASE if not account.address.case_sensitive else 0) + flags=( + re.IGNORECASE if not account.address.case_sensitive + else 0)) for seen_name, seen_address in candidate_addresses: - if regex.match(seen_address): - logging.debug("match!: '%s' '%s'", seen_address, alias) - if settings.get(action + '_force_realname'): - realname = account.realname - else: - realname = seen_name - if settings.get(action + '_force_address'): - address = account.address - else: - address = seen_address - - logging.debug('using realname: "%s"', realname) - logging.debug('using address: %s', address) - - from_value = formataddr((realname, str(address))) - return from_value, account + if not regex.match(seen_address): + continue + logging.debug("match!: '%s' '%s'", seen_address, alias) + if settings.get(action + '_force_realname'): + realname = account.realname + else: + realname = seen_name + if settings.get(action + '_force_address'): + address = account.address + else: + address = seen_address + + logging.debug('using realname: "%s"', realname) + logging.debug('using address: %s', address) + + from_value = formataddr((realname, str(address))) + return from_value, account # revert to default account if nothing found account = my_accounts[0] @@ -241,7 +245,11 @@ class ReplyCommand(Command): # Reply-To is standart reply target RFC 2822:, RFC 1036: 2.2.1 # X-BeenThere is needed by sourceforge ML also winehq # X-Mailing-List is also standart and is used by git-send-mail - to = mail['Reply-To'] or mail['X-BeenThere'] or mail['X-Mailing-List'] + to = ( + mail['Reply-To'] + or mail['X-BeenThere'] + or mail['X-Mailing-List'] + ) # Some mail server (gmail) will not resend you own mail, so you # have to deal with the one in sent if to is None: |