Skip to content

Commit

Permalink
Merge branch '0.3.6-feature-aliases-plus-780' into testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pazz committed Jul 31, 2015
2 parents e2ca2dd + b70d1e1 commit 38f4b42
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
14 changes: 9 additions & 5 deletions alot/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Account(object):
"""this accounts main email address"""
aliases = []
"""list of alternative addresses"""
alias_regexp = []
"""regex matching alternative addresses"""
realname = None
"""real name used to format from-headers"""
gpg_key = None
Expand All @@ -47,13 +49,15 @@ class Account(object):
"""addressbook (:class:`addressbook.AddressBook`)
managing this accounts contacts"""

def __init__(self, address=None, aliases=None, realname=None,
gpg_key=None, signature=None, signature_filename=None,
signature_as_attachment=False, sent_box=None,
sent_tags=['sent'], draft_box=None, draft_tags=['draft'],
abook=None, sign_by_default=False, **rest):
def __init__(self, address=None, aliases=None, alias_regexp=None,
realname=None, gpg_key=None, signature=None,
signature_filename=None, signature_as_attachment=False,
sent_box=None, sent_tags=['sent'], draft_box=None,
draft_tags=['draft'], abook=None, sign_by_default=False,
**rest):
self.address = address
self.aliases = aliases
self.alias_regexp = alias_regexp
self.realname = realname
self.gpg_key = gpg_key
self.signature = signature
Expand Down
6 changes: 4 additions & 2 deletions alot/commands/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ 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 = account.get_addresses()
acc_addresses = map(re.escape, account.get_addresses())
if account.alias_regexp is not None:
acc_addresses.append(account.alias_regexp)
for alias in acc_addresses:
if realname is not None:
break
regex = re.compile(re.escape(alias), flags=re.IGNORECASE)
regex = re.compile('^' + alias + '$', flags=re.IGNORECASE)
for seen_name, seen_address in candidate_addresses:
if regex.match(seen_address):
logging.debug("match!: '%s' '%s'" % (seen_address, alias))
Expand Down
3 changes: 3 additions & 0 deletions alot/defaults/alot.rc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ prefer_plaintext = boolean(default=False)
# used to clear your addresses/ match account when formatting replies
aliases = force_list(default=list())

# a regex for catching further aliases (like + extensions).
alias_regexp = string(default=None)

# sendmail command. This is the shell command used to send out mails via the sendmail protocol
sendmail_command = string(default='sendmail -t')

Expand Down
1 change: 1 addition & 0 deletions docs/source/configuration/accounts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Here is an example configuration
[[work]]
realname = Bruce Wayne
address = b.wayne@wayneenterprises.com
alias_regexp = b.wayne\+.+@wayneenterprises.com
gpg_key = D7D6C5AA
sendmail_command = msmtp --account=wayne -t
sent_box = maildir:///home/bruce/mail/work/Sent
Expand Down

0 comments on commit 38f4b42

Please sign in to comment.