summaryrefslogtreecommitdiff
path: root/alot/settings
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2017-08-15 19:32:20 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2017-08-15 19:32:20 +0100
commitd270d5dd96cdf89143782e0592379a680119372a (patch)
tree9bed8ce3a6f20e9243ff28b352254c6bb5fc04a8 /alot/settings
parent33fb2b66ec1fcb22114fd7a424f42eb081f0eae6 (diff)
ignore realname part in get_account_by_address
This allows to simply pass the content of a messages' From-header value when determining an account to send/save/encrypt from.
Diffstat (limited to 'alot/settings')
-rw-r--r--alot/settings/manager.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/alot/settings/manager.py b/alot/settings/manager.py
index 796f98a5..01eec053 100644
--- a/alot/settings/manager.py
+++ b/alot/settings/manager.py
@@ -9,6 +9,7 @@ import logging
import mailcap
import os
import re
+import email
from configobj import ConfigObj, Section
from ..account import SendmailAccount
@@ -112,7 +113,7 @@ class SettingsManager(object):
if themestring:
# This is a python for/else loop
# https://docs.python.org/3/reference/compound_stmts.html#for
- #
+ #
# tl/dr; If the loop loads a theme it breaks. If it doesn't break,
# then it raises a ConfigError.
for dir_ in itertools.chain([themes_dir], data_dirs):
@@ -433,7 +434,7 @@ class SettingsManager(object):
def get_account_by_address(self, address, return_default=False):
"""returns :class:`Account` for a given email address (str)
- :param str address: address to look up
+ :param str address: address to look up. A realname part will be ignored.
:param bool return_default: If True and no address can be found, then
the default account wil be returned
:rtype: :class:`Account`
@@ -441,6 +442,7 @@ class SettingsManager(object):
found. Thsi includes if return_default is True and there are no
accounts defined.
"""
+ _, address = email.utils.parseaddr(address)
for myad in self.get_addresses():
if myad == address:
return self._accountmap[myad]