Skip to content

Commit

Permalink
add attachments directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Jacob committed Feb 2, 2011
1 parent ea9751b commit f3423cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
15 changes: 2 additions & 13 deletions pyramid_mailer/message.py
Expand Up @@ -163,23 +163,12 @@ def add_bcc(self, recipient):

self.bcc.append(recipient)

def attach(self,
filename=None,
content_type=None,
data=None,
disposition=None):
def attach(self, attachment):

"""
Adds an attachment to the message.
:param filename: filename of attachment
:param content_type: file mimetype
:param data: the raw file data
:param disposition: content-disposition (if any)
Adds an IAttachment instance to the message.
"""

attachment = Attachment(filename, content_type, data, disposition)

self.attachments.append(attachment)


5 changes: 3 additions & 2 deletions pyramid_mailer/tests.py
Expand Up @@ -128,13 +128,14 @@ def test_cc(self):
def test_attach(self):

from pyramid_mailer.message import Message
from pyramid_mailer.message import Attachment

msg = Message(subject="testing",
recipients=["to@example.com"],
body="testing")

msg.attach(data="this is a test",
content_type="text/plain")
msg.attach(Attachment(data="this is a test",
content_type="text/plain"))


a = msg.attachments[0]
Expand Down

0 comments on commit f3423cc

Please sign in to comment.