##// END OF EJS Templates
fixes #481 rhodecode emails are sent without Date header...
marcink -
r2452:d95ef658 beta
parent child Browse files
Show More
@@ -50,6 +50,7 b' fixes'
50 - fixed issue #459. Changed the way of obtaining logger in reindex task.
50 - fixed issue #459. Changed the way of obtaining logger in reindex task.
51 - fixed #453 added ID field in whoosh SCHEMA that solves the issue of
51 - fixed #453 added ID field in whoosh SCHEMA that solves the issue of
52 reindexing modified files
52 reindexing modified files
53 - fixes #481 rhodecode emails are sent without Date header
53
54
54 1.3.6 (**2012-05-17**)
55 1.3.6 (**2012-05-17**)
55 ----------------------
56 ----------------------
@@ -3,6 +3,7 b' from rhodecode.lib.rcmail.response impor'
3 from rhodecode.lib.rcmail.exceptions import BadHeaders
3 from rhodecode.lib.rcmail.exceptions import BadHeaders
4 from rhodecode.lib.rcmail.exceptions import InvalidMessage
4 from rhodecode.lib.rcmail.exceptions import InvalidMessage
5
5
6
6 class Attachment(object):
7 class Attachment(object):
7 """
8 """
8 Encapsulates file attachment information.
9 Encapsulates file attachment information.
@@ -134,13 +135,13 b' class Message(object):'
134 """
135 """
135
136
136 if not self.recipients:
137 if not self.recipients:
137 raise InvalidMessage, "No recipients have been added"
138 raise InvalidMessage("No recipients have been added")
138
139
139 if not self.body and not self.html:
140 if not self.body and not self.html:
140 raise InvalidMessage, "No body has been set"
141 raise InvalidMessage("No body has been set")
141
142
142 if not self.sender:
143 if not self.sender:
143 raise InvalidMessage, "No sender address has been set"
144 raise InvalidMessage("No sender address has been set")
144
145
145 if self.is_bad_headers():
146 if self.is_bad_headers():
146 raise BadHeaders
147 raise BadHeaders
@@ -364,6 +364,7 b' def to_message(mail, separator="; "):'
364
364
365 return out
365 return out
366
366
367
367 class MIMEPart(MIMEBase):
368 class MIMEPart(MIMEBase):
368 """
369 """
369 A reimplementation of nearly everything in email.mime to be more useful
370 A reimplementation of nearly everything in email.mime to be more useful
@@ -387,7 +388,8 b' class MIMEPart(MIMEBase):'
387 self.set_payload(encoded, charset=charset)
388 self.set_payload(encoded, charset=charset)
388
389
389 def extract_payload(self, mail):
390 def extract_payload(self, mail):
390 if mail.body == None: return # only None, '' is still ok
391 if mail.body == None:
392 return # only None, '' is still ok
391
393
392 ctype, ctype_params = mail.content_encoding['Content-Type']
394 ctype, ctype_params = mail.content_encoding['Content-Type']
393 cdisp, cdisp_params = mail.content_encoding['Content-Disposition']
395 cdisp, cdisp_params = mail.content_encoding['Content-Disposition']
@@ -415,7 +417,8 b' class MIMEPart(MIMEBase):'
415
417
416
418
417 def header_to_mime_encoding(value, not_email=False, separator=", "):
419 def header_to_mime_encoding(value, not_email=False, separator=", "):
418 if not value: return ""
420 if not value:
421 return ""
419
422
420 encoder = Charset(DEFAULT_ENCODING)
423 encoder = Charset(DEFAULT_ENCODING)
421 if type(value) == list:
424 if type(value) == list:
@@ -424,6 +427,7 b' def header_to_mime_encoding(value, not_e'
424 else:
427 else:
425 return properly_encode_header(value, encoder, not_email)
428 return properly_encode_header(value, encoder, not_email)
426
429
430
427 def properly_encode_header(value, encoder, not_email):
431 def properly_encode_header(value, encoder, not_email):
428 """
432 """
429 The only thing special (weird) about this function is that it tries
433 The only thing special (weird) about this function is that it tries
@@ -21,10 +21,11 b''
21 #
21 #
22 # You should have received a copy of the GNU General Public License
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24
24 import time
25 import logging
25 import logging
26 import smtplib
26 import smtplib
27 from socket import sslerror
27 from socket import sslerror
28 from email.utils import formatdate
28 from rhodecode.lib.rcmail.message import Message
29 from rhodecode.lib.rcmail.message import Message
29
30
30
31
@@ -59,8 +60,11 b' class SmtpMailer(object):'
59
60
60 if isinstance(recipients, basestring):
61 if isinstance(recipients, basestring):
61 recipients = [recipients]
62 recipients = [recipients]
63 headers = {
64 'Date': formatdate(time.time())
65 }
62 msg = Message(subject, recipients, body, html, self.mail_from,
66 msg = Message(subject, recipients, body, html, self.mail_from,
63 recipients_separator=", ")
67 recipients_separator=", ", extra_headers=headers)
64 raw_msg = msg.to_message()
68 raw_msg = msg.to_message()
65
69
66 if self.ssl:
70 if self.ssl:
General Comments 0
You need to be logged in to leave comments. Login now