def _build_mail(self): """ Download the given url and build an attachment with the contents. In case that the download fails, a text mail with the error is built instead. """ success, dl = self._download_url(self.url) if not success: return build_text_mail(dl) msg = MIMEMultipart() msg.attach(build_text_mail(u"Downloaded website included as an attachment")) part = MIMEBase("application", "octet-stream") part.set_payload(dl) email.Encoders.encode_base64(part) part.add_header("Content-Disposition", 'attachment; filename="%s"' % "website.html") msg.attach(part) return msg
def _build_mail(self, msg_list): '''Returns a mail that contains all the given mails as a single text''' return build_text_mail(self._merge_mails(msg_list))