Mercurial > kallithea
changeset 2452:d95ef6587bca beta
fixes #481 rhodecode emails are sent without Date header
- small code cleanup in mailing
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 13 Jun 2012 23:44:32 +0200 |
parents | 402a96fcfa22 |
children | d2a528b60e50 |
files | docs/changelog.rst rhodecode/lib/rcmail/message.py rhodecode/lib/rcmail/response.py rhodecode/lib/rcmail/smtp_mailer.py |
diffstat | 4 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/changelog.rst Wed Jun 13 23:27:33 2012 +0200 +++ b/docs/changelog.rst Wed Jun 13 23:44:32 2012 +0200 @@ -50,6 +50,7 @@ - fixed issue #459. Changed the way of obtaining logger in reindex task. - fixed #453 added ID field in whoosh SCHEMA that solves the issue of reindexing modified files +- fixes #481 rhodecode emails are sent without Date header 1.3.6 (**2012-05-17**) ----------------------
--- a/rhodecode/lib/rcmail/message.py Wed Jun 13 23:27:33 2012 +0200 +++ b/rhodecode/lib/rcmail/message.py Wed Jun 13 23:44:32 2012 +0200 @@ -3,6 +3,7 @@ from rhodecode.lib.rcmail.exceptions import BadHeaders from rhodecode.lib.rcmail.exceptions import InvalidMessage + class Attachment(object): """ Encapsulates file attachment information. @@ -134,13 +135,13 @@ """ if not self.recipients: - raise InvalidMessage, "No recipients have been added" + raise InvalidMessage("No recipients have been added") if not self.body and not self.html: - raise InvalidMessage, "No body has been set" + raise InvalidMessage("No body has been set") if not self.sender: - raise InvalidMessage, "No sender address has been set" + raise InvalidMessage("No sender address has been set") if self.is_bad_headers(): raise BadHeaders
--- a/rhodecode/lib/rcmail/response.py Wed Jun 13 23:27:33 2012 +0200 +++ b/rhodecode/lib/rcmail/response.py Wed Jun 13 23:44:32 2012 +0200 @@ -364,6 +364,7 @@ return out + class MIMEPart(MIMEBase): """ A reimplementation of nearly everything in email.mime to be more useful @@ -387,7 +388,8 @@ self.set_payload(encoded, charset=charset) def extract_payload(self, mail): - if mail.body == None: return # only None, '' is still ok + if mail.body == None: + return # only None, '' is still ok ctype, ctype_params = mail.content_encoding['Content-Type'] cdisp, cdisp_params = mail.content_encoding['Content-Disposition'] @@ -415,7 +417,8 @@ def header_to_mime_encoding(value, not_email=False, separator=", "): - if not value: return "" + if not value: + return "" encoder = Charset(DEFAULT_ENCODING) if type(value) == list: @@ -424,6 +427,7 @@ else: return properly_encode_header(value, encoder, not_email) + def properly_encode_header(value, encoder, not_email): """ The only thing special (weird) about this function is that it tries
--- a/rhodecode/lib/rcmail/smtp_mailer.py Wed Jun 13 23:27:33 2012 +0200 +++ b/rhodecode/lib/rcmail/smtp_mailer.py Wed Jun 13 23:44:32 2012 +0200 @@ -21,10 +21,11 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. - +import time import logging import smtplib from socket import sslerror +from email.utils import formatdate from rhodecode.lib.rcmail.message import Message @@ -59,8 +60,11 @@ if isinstance(recipients, basestring): recipients = [recipients] + headers = { + 'Date': formatdate(time.time()) + } msg = Message(subject, recipients, body, html, self.mail_from, - recipients_separator=", ") + recipients_separator=", ", extra_headers=headers) raw_msg = msg.to_message() if self.ssl: