fix sent mails
This commit is contained in:
parent
612fcd1cf5
commit
d59da7c030
2 changed files with 9 additions and 7 deletions
|
|
@ -40,10 +40,10 @@ class Message:
|
||||||
return int(time.strftime('%Y%m%d%H%M%S', self.get_date().timetuple()))
|
return int(time.strftime('%Y%m%d%H%M%S', self.get_date().timetuple()))
|
||||||
|
|
||||||
def get_full_id(self):
|
def get_full_id(self):
|
||||||
return '%s.%s' % (self.id, self.thread_id)
|
return '%s.%s' % (self.thread_id, self.id)
|
||||||
|
|
||||||
def get_full_reply_id(self):
|
def get_full_reply_id(self):
|
||||||
return '%s.%s' % (self.reply_id, self.thread_id)
|
return '%s.%s' % (self.thread_id, self.reply_id)
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
return self.id
|
return self.id
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ from email.Header import Header
|
||||||
from email.Utils import parseaddr, formataddr
|
from email.Utils import parseaddr, formataddr
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
from html2text import html2text
|
||||||
|
|
||||||
from weboob import Weboob
|
from weboob import Weboob
|
||||||
from weboob.capabilities.messages import ICapMessages
|
from weboob.capabilities.messages import ICapMessages
|
||||||
|
|
@ -61,14 +62,14 @@ class Monboob(BaseApplication):
|
||||||
|
|
||||||
reply_id = ''
|
reply_id = ''
|
||||||
if mail.get_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 = u'%s%s' % ((reply_id) and 'Re: ' or '', mail.get_title())
|
subject = mail.get_title()
|
||||||
sender = u'%s <%s.%s.%s@%s>' % (mail.get_from(), backend_name, mail.get_thread_id(), mail.get_id(), domain)
|
sender = u'%s <%s@%s>' % (mail.get_from(), backend_name, domain)
|
||||||
|
|
||||||
# assume that get_date() returns an UTC datetime
|
# assume that get_date() returns an UTC datetime
|
||||||
date = time.strftime('%a, %d %b %Y %H:%M:%S +0000', mail.get_date().timetuple())
|
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)
|
msg_id = u'<%s.%s@%s>' % (backend_name, mail.get_full_id(), domain)
|
||||||
body = mail.get_content()
|
body = html2text(mail.get_content())
|
||||||
|
|
||||||
if mail.get_signature():
|
if mail.get_signature():
|
||||||
body += u'\n\n-- \n'
|
body += u'\n\n-- \n'
|
||||||
|
|
@ -112,6 +113,7 @@ class Monboob(BaseApplication):
|
||||||
|
|
||||||
# Send the message via SMTP to localhost:25
|
# Send the message via SMTP to localhost:25
|
||||||
smtp = SMTP(self.config.get('smtp'))
|
smtp = SMTP(self.config.get('smtp'))
|
||||||
|
print 'Send mail from <%s> to <%s>' % (sender, recipient)
|
||||||
smtp.sendmail(sender, recipient, msg.as_string())
|
smtp.sendmail(sender, recipient, msg.as_string())
|
||||||
smtp.quit()
|
smtp.quit()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue