Changeset - d95ef6587bca
[Not reviewed]
beta
0 4 0
Marcin Kuzminski - 13 years ago 2012-06-13 23:44:32
marcin@python-works.com
fixes #481 rhodecode emails are sent without Date header
- small code cleanup in mailing
4 files changed with 17 insertions and 7 deletions:
0 comments (0 inline, 0 general)
docs/changelog.rst
Show inline comments
 
@@ -50,6 +50,7 @@ fixes
 
- 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**)
 
----------------------
rhodecode/lib/rcmail/message.py
Show inline comments
 
@@ -3,6 +3,7 @@ from rhodecode.lib.rcmail.response impor
 
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 @@ class Message(object):
 
        """
 

	
 
        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
rhodecode/lib/rcmail/response.py
Show inline comments
 
@@ -364,6 +364,7 @@ def to_message(mail, separator="; "):
 

	
 
    return out
 

	
 

	
 
class MIMEPart(MIMEBase):
 
    """
 
    A reimplementation of nearly everything in email.mime to be more useful
 
@@ -387,7 +388,8 @@ class MIMEPart(MIMEBase):
 
        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 @@ class MIMEPart(MIMEBase):
 

	
 

	
 
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 @@ def header_to_mime_encoding(value, not_e
 
    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
rhodecode/lib/rcmail/smtp_mailer.py
Show inline comments
 
@@ -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 @@ class SmtpMailer(object):
 

	
 
        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:
0 comments (0 inline, 0 general)