diff options
author | josch <j.schauer@email.de> | 2013-04-23 11:34:06 +0200 |
---|---|---|
committer | josch <j.schauer@email.de> | 2013-04-23 15:46:29 +0200 |
commit | 833a8d65022b2508c5f753b080270f0bf193a4f3 (patch) | |
tree | 3224576670f8a41f7c3d1b25c9d51b2a18b2c67c /alot | |
parent | 7642647db734ef5ef36905bfb532816b3c22e7c2 (diff) |
set and honor mail-followup-to header
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/thread.py | 46 | ||||
-rw-r--r-- | alot/defaults/alot.rc.spec | 11 |
2 files changed, 45 insertions, 12 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py index 38a8994c..6984cfd0 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -161,6 +161,7 @@ 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: @@ -171,25 +172,46 @@ class ReplyCommand(Command): 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 anyways + followupto = self.clear_my_address( + my_addresses, mail.get_all('Mail-Followup-To', [])) + 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 address in the recipients 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) |