diff --git a/rhodecode/lib/rcmail/message.py b/rhodecode/lib/rcmail/message.py --- a/rhodecode/lib/rcmail/message.py +++ b/rhodecode/lib/rcmail/message.py @@ -13,11 +13,11 @@ class Attachment(object): :param disposition: content-disposition (if any) """ - def __init__(self, - filename=None, - content_type=None, + def __init__(self, + filename=None, + content_type=None, data=None, - disposition=None): + disposition=None): self.filename = filename self.content_type = content_type @@ -47,11 +47,11 @@ class Message(object): :param attachments: list of Attachment instances """ - def __init__(self, - subject=None, - recipients=None, - body=None, - html=None, + def __init__(self, + subject=None, + recipients=None, + body=None, + html=None, sender=None, cc=None, bcc=None, @@ -78,7 +78,7 @@ class Message(object): """ Returns raw email.Message instance.Validates message first. """ - + self.validate() return self.get_response().to_message() @@ -88,7 +88,7 @@ class Message(object): Creates a Lamson MailResponse instance """ - response = MailResponse(Subject=self.subject, + response = MailResponse(Subject=self.subject, To=self.recipients, From=self.sender, Body=self.body, @@ -102,20 +102,20 @@ class Message(object): for attachment in self.attachments: - response.attach(attachment.filename, - attachment.content_type, - attachment.data, + response.attach(attachment.filename, + attachment.content_type, + attachment.data, attachment.disposition) response.update(self.extra_headers) return response - + def is_bad_headers(self): """ Checks for bad headers i.e. newlines in subject, sender or recipients. """ - + headers = [self.subject, self.sender] headers += list(self.send_to) headers += self.extra_headers.values() @@ -125,7 +125,7 @@ class Message(object): if c in val: return True return False - + def validate(self): """ Checks if message is valid and raises appropriate exception. @@ -146,15 +146,15 @@ class Message(object): def add_recipient(self, recipient): """ Adds another recipient to the message. - + :param recipient: email address of recipient. """ - + self.recipients.append(recipient) def add_cc(self, recipient): """ - Adds an email address to the CC list. + Adds an email address to the CC list. :param recipient: email address of recipient. """ @@ -163,7 +163,7 @@ class Message(object): def add_bcc(self, recipient): """ - Adds an email address to the BCC list. + Adds an email address to the BCC list. :param recipient: email address of recipient. """ @@ -178,5 +178,3 @@ class Message(object): """ self.attachments.append(attachment) - -