diff --git a/weboob/frontends/monboob/scripts/monboob b/weboob/frontends/monboob/scripts/monboob index 08e58f6f753a7c3e18d4cd281360f28419ff5dba..f053dd781247891d68a4bb983fd27d1b3fe1459c 100755 --- a/weboob/frontends/monboob/scripts/monboob +++ b/weboob/frontends/monboob/scripts/monboob @@ -37,7 +37,8 @@ class Monboob(BaseApplication): CONFIG = {'interval': 15, 'domain': 'weboob.example.org', 'recipient': 'weboob@example.org', - 'smtp': 'localhost'} + 'smtp': 'localhost', + 'html': False} def main(self, argv): self.load_config() @@ -54,26 +55,35 @@ class Monboob(BaseApplication): def process(self): for name, backend in self.weboob.iter_backends(): for message in backend.iter_new_messages(): - self.send_email(name, message) + self.send_email(backend, message) - def send_email(self, backend_name, mail): + def send_email(self, backend, mail): domain = self.config.get('domain') recipient = self.config.get('recipient') reply_id = '' if mail.get_reply_id(): - reply_id = u'<%s.%s@%s>' % (backend_name, mail.get_full_reply_id(), domain) + reply_id = u'<%s.%s@%s>' % (backend.name, mail.get_full_reply_id(), domain) subject = mail.get_title() - sender = u'%s <%s@%s>' % (mail.get_from(), backend_name, domain) + sender = u'%s <%s@%s>' % (mail.get_from(), backend.name, domain) # assume that get_date() returns an UTC datetime date = time.strftime('%a, %d %b %Y %H:%M:%S +0000', mail.get_date().timetuple()) - msg_id = u'<%s.%s@%s>' % (backend_name, mail.get_full_id(), domain) - body = html2text(mail.get_content()) + msg_id = u'<%s.%s@%s>' % (backend.name, mail.get_full_id(), domain) + + if self.config.get('html'): + body = mail.get_content() + content_type = 'html' + else: + body = html2text(mail.get_content()) + content_type = 'plain' if mail.get_signature(): - body += u'\n\n-- \n' - body += mail.get_signature() + if self.config.get('html'): + body += u'
--
%s