1.1 --- a/imiptools/mail.py Fri Oct 27 22:26:10 2017 +0200
1.2 +++ b/imiptools/mail.py Mon Oct 30 23:14:45 2017 +0100
1.3 @@ -144,7 +144,7 @@
1.4 """
1.5 Return a simple summary using details from 'msg' and the given 'parts'.
1.6 Information messages provided amongst the parts by the handlers will be
1.7 - merged into the preamble so that mail programs will show them
1.8 + merged into a single text part so that mail programs will show them
1.9 immediately.
1.10 """
1.11
1.12 @@ -157,12 +157,16 @@
1.13 """
1.14 Wrap 'msg' and provide the given 'parts' as the primary content.
1.15 Information messages provided amongst the parts by the handlers will be
1.16 - merged into the preamble so that mail programs will show them
1.17 + merged into a single text part so that mail programs will show them
1.18 immediately.
1.19 """
1.20
1.21 message = self._make_container_for_parts(parts, True)
1.22 payload = message.get_payload()
1.23 +
1.24 + # The original message is placed in a mailbox part for reference,
1.25 + # attached to the rest of the primary content parts.
1.26 +
1.27 payload.append(MIMEMessage(msg))
1.28 self._copy_headers(message, msg)
1.29 return message
1.30 @@ -193,14 +197,30 @@
1.31 else:
1.32 info = []
1.33
1.34 - # Insert a preamble message before any calendar information messages.
1.35 + # Provide a preamble message before any other data.
1.36 +
1.37 + preamble = self.preamble_text or \
1.38 + self.gettext and self.gettext(PREAMBLE_TEXT) or PREAMBLE_TEXT
1.39 +
1.40 + # Provide a mixture of aggregated message parts.
1.41 +
1.42 + message = parts and MIMEMultipart("mixed", _subparts=parts) or None
1.43 +
1.44 + # Provide an informational message using the aggregated information.
1.45
1.46 - info.insert(0, self.preamble_text or
1.47 - self.gettext and self.gettext(PREAMBLE_TEXT) or PREAMBLE_TEXT)
1.48 + info_message = info and MIMEText("\n\n".join(info)) or None
1.49 +
1.50 + # Wrap the information and message parts.
1.51
1.52 - message = MIMEMultipart("mixed", _subparts=parts)
1.53 - message.preamble = "\n\n".join(info)
1.54 - return message
1.55 + subparts = []
1.56 + if info_message:
1.57 + subparts.append(info_message)
1.58 + if message:
1.59 + subparts.append(message)
1.60 +
1.61 + top = MIMEMultipart("alternative", _subparts=subparts)
1.62 + top.preamble = preamble
1.63 + return top
1.64
1.65 def _merge_calendar_info_parts(self, parts):
1.66