1.1 --- a/imiptools/__init__.py Sun Oct 01 16:38:10 2017 +0200
1.2 +++ b/imiptools/__init__.py Sun Oct 01 17:17:41 2017 +0200
1.3 @@ -80,7 +80,6 @@
1.4 """
1.5
1.6 msg = message_from_file(f)
1.7 - senders = get_addresses(get_all_values(msg, "Reply-To") or get_all_values(msg, "From") or [])
1.8
1.9 messenger = self.messenger
1.10 store = self.get_store()
1.11 @@ -93,10 +92,12 @@
1.12 # messages.
1.13
1.14 if not self.outgoing_only:
1.15 + senders = get_addresses(get_all_values(msg, "Reply-To") or get_all_values(msg, "From") or [])
1.16 original_recipients = original_recipients or get_addresses(get_all_values(msg, "To") or [])
1.17 + users = []
1.18 +
1.19 for recipient in original_recipients:
1.20 - Recipient(get_uri(recipient), messenger, store, publisher, journal, preferences_dir, self.handlers, self.outgoing_only, self.debug
1.21 - ).process(msg, senders)
1.22 + users.append(get_uri(recipient))
1.23
1.24 # However, outgoing messages do not usually presume anything about the
1.25 # eventual recipients and focus on the sender instead. If possible, the
1.26 @@ -106,9 +107,20 @@
1.27 # None and deduced from the object content later.
1.28
1.29 else:
1.30 - senders = [sender for sender in get_addresses(get_all_values(msg, "From") or []) if sender != settings["MESSAGE_SENDER"]]
1.31 - Recipient(senders and senders[0] or None, messenger, store, publisher, journal, preferences_dir, self.handlers, self.outgoing_only, self.debug
1.32 - ).process(msg, senders)
1.33 + senders = []
1.34 +
1.35 + for sender in get_addresses(get_all_values(msg, "From") or []):
1.36 + if sender != settings["MESSAGE_SENDER"]:
1.37 + senders.append(sender)
1.38 +
1.39 + users = [senders and get_uri(senders[0]) or None]
1.40 +
1.41 + # Process the message for each recipient.
1.42 +
1.43 + for user in users:
1.44 + Recipient(user, messenger, store, publisher, journal,
1.45 + preferences_dir, self.handlers, self.outgoing_only,
1.46 + self.debug).process(msg, senders)
1.47
1.48 def process_args(self, args, stream):
1.49