summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2013-05-04 18:28:01 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2013-05-04 18:28:01 +0100
commit10a763910c00a299ef9e78d9db6838256e14b906 (patch)
tree7f954f871c5f7a73316d558a00f03e3ca98dc85b /alot
parentf3a00463291630cbac317eb03fded3f436506275 (diff)
parentce59541e92dc2b163a269e3fbacecb0175b3ffaa (diff)
Merge branch '0.3.4-feature-mail-followup-to-599'
Diffstat (limited to 'alot')
-rw-r--r--alot/commands/thread.py70
-rw-r--r--alot/defaults/alot.rc.spec11
2 files changed, 58 insertions, 23 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 38a8994c..8ec46b84 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -55,21 +55,22 @@ def determine_sender(mail, action='reply'):
my_accounts = settings.get_accounts()
assert my_accounts, 'no accounts set!'
- # extract list of recipients to check for my address
- recipients = getaddresses(mail.get_all('To', [])
- + mail.get_all('Cc', [])
- + mail.get_all('Delivered-To', []))
-
- logging.debug('recipients: %s' % recipients)
- # pick the most important account that has an address in recipients
- # and use that accounts realname and the found recipient address
+ # extract list of addresses to check for my address
+ candidate_addresses = getaddresses(mail.get_all('To', []) +
+ mail.get_all('Cc', []) +
+ mail.get_all('Delivered-To', []) +
+ mail.get_all('From', []))
+
+ logging.debug('candidate addresses: %s' % candidate_addresses)
+ # 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()
for alias in acc_addresses:
if realname is not None:
break
regex = re.compile(alias)
- for seen_name, seen_address in recipients:
+ 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'):
@@ -161,35 +162,58 @@ class ReplyCommand(Command):
sender = mail['Reply-To'] or mail['From']
my_addresses = settings.get_addresses()
sender_address = parseaddr(sender)[1]
+ cc = ''
# check if reply is to self sent message
if sender_address in my_addresses:
recipients = [mail['To']]
- logging.debug('Replying to own message, set recipients to: %s'
- % recipients)
+ emsg = 'Replying to own message, set recipients to: %s' \
+ % recipients
+ logging.debug(emsg)
else:
recipients = [sender]
if self.groupreply:
- if sender != mail['From']:
- recipients.append(mail['From'])
+ # make sure that our own address is not included
+ # if the message was self-sent, then our address is not included
+ MFT = mail.get_all('Mail-Followup-To', [])
+ followupto = self.clear_my_address(my_addresses, MFT)
+ if followupto and settings.get('honor_followup_to'):
+ logging.debug('honor followup to: %s', followupto)
+ recipients = [followupto]
+ # since Mail-Followup-To was set, ignore the Cc header
+ else:
+ if sender != mail['From']:
+ recipients.append(mail['From'])
- # append To addresses if not replying to self sent message
- if sender_address not in my_addresses:
- cleared = self.clear_my_address(
- my_addresses, mail.get_all('To', []))
- recipients.append(cleared)
+ # append To addresses if not replying to self sent message
+ if sender_address not in my_addresses:
+ cleared = self.clear_my_address(
+ my_addresses, mail.get_all('To', []))
+ recipients.append(cleared)
- # copy cc for group-replies
- if 'Cc' in mail:
- cc = self.clear_my_address(
- my_addresses, mail.get_all('Cc', []))
- envelope.add('Cc', decode_header(cc))
+ # copy cc for group-replies
+ if 'Cc' in mail:
+ cc = self.clear_my_address(
+ my_addresses, mail.get_all('Cc', []))
+ envelope.add('Cc', decode_header(cc))
to = ', '.join(recipients)
logging.debug('reply to: %s' % to)
envelope.add('To', decode_header(to))
+ # if any of the recipients is a mailinglist that we are subscribed to,
+ # set Mail-Followup-To header so that duplicates are avoided
+ if settings.get('followup_to'):
+ # to and cc are already cleared of our own address
+ allrecipients = [to] + [cc]
+ lists = settings.get('mailinglists')
+ # check if any recipient address matches a known mailing list
+ if any([addr in lists for n, addr in getaddresses(allrecipients)]):
+ followupto = ', '.join(allrecipients)
+ logging.debug('mail followup to: %s' % followupto)
+ envelope.add('Mail-Followup-To', decode_header(followupto))
+
# set In-Reply-To header
envelope.add('In-Reply-To', '<%s>' % self.message.get_message_id())
diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec
index 67767551..da158311 100644
--- a/alot/defaults/alot.rc.spec
+++ b/alot/defaults/alot.rc.spec
@@ -200,6 +200,17 @@ bounce_force_realname = boolean(default=True)
# Set this to False to use the address string as received in the original message.
bounce_force_address = boolean(default=False)
+# When group-reply-ing to an email that has the "Mail-Followup-To" header set,
+# use the content of this header as the new "To" header and leave the "Cc"
+# header empty
+honor_followup_to = boolean(default=False)
+
+# When one of the recipients of an email is a subscribed mailing list, set the
+# "Mail-Followup-To" header to the list of recipients without yourself
+followup_to = boolean(default=False)
+
+# The list of addresses associated to the mailinglists you are subscribed to
+mailinglists = force_list(default=list())
# prefer plaintext alternatives over html content in multipart/alternative
prefer_plaintext = boolean(default=False)