Exemple #1
0
    def create_message(self, subject, txtMessage, htmlMessage, origMesg):
        container = MIMEMultipart('mixed')
        container['Subject'] = str(Header(subject, UTF8))
        # --=mpj17=-- Similar to the call in MessageSender, but we
        #   always want the default.
        container['From'] = self.from_header_from_address(None)
        container['To'] = self.to_header_from_addresses(None)

        messageTextContainer = MIMEMultipart('alternative')
        container.attach(messageTextContainer)

        txt = MIMEText(txtMessage.encode(UTF8), 'plain', UTF8)
        messageTextContainer.attach(txt)

        html = MIMEText(htmlMessage.encode(UTF8), 'html', UTF8)
        messageTextContainer.attach(html)

        msg = message_from_string(origMesg)
        m = MIMEMessage(msg)
        m['Content-Description'] = 'Returned Message: %s' % \
            msg['Subject']
        m['Content-Disposition'] = 'inline'
        m.set_param('name', 'Returned message')
        del m['MIME-Version']
        container.attach(m)

        retval = container.as_string()
        assert retval
        return retval
    def create_message(self, subject, txtMessage, htmlMessage, origMesg):
        container = MIMEMultipart('mixed')
        container['Subject'] = str(Header(subject, UTF8))
        # --=mpj17=-- Similar to the call in MessageSender, but we
        #   always want the default.
        container['From'] = self.from_header_from_address(None)
        container['To'] = self.to_header_from_addresses(None)

        messageTextContainer = MIMEMultipart('alternative')
        container.attach(messageTextContainer)

        txt = MIMEText(txtMessage.encode(UTF8), 'plain', UTF8)
        messageTextContainer.attach(txt)

        html = MIMEText(htmlMessage.encode(UTF8), 'html', UTF8)
        messageTextContainer.attach(html)

        msg = message_from_string(origMesg)
        m = MIMEMessage(msg)
        m['Content-Description'] = 'Returned Message: %s' % \
            msg['Subject']
        m['Content-Disposition'] = 'inline'
        m.set_param('name', 'Returned message')
        del m['MIME-Version']
        container.attach(m)

        retval = container.as_string()
        assert retval
        return retval
 def create_return_message(msg):
     retval = MIMEMessage(msg)
     s = msg.get('Subject', 'No subject').decode('ascii', 'ignore')
     retval['Content-Description'] = 'Returned message: {0}'.format(s)
     retval['Content-Disposition'] = 'inline'
     retval.set_param('name', 'Returned message')
     del retval['MIME-Version']
     return retval