diff --git a/docs/examples.rst b/docs/examples.rst index d4ad6dc..d50e7d2 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -28,8 +28,8 @@ Attach files or inline images: .. code-block:: python - message.attach(data=open('event.ics'), filename='Event.ics') - message.attach(data=open('image.png'), filename='image.png', + message.attach(data=open('event.ics', 'rb'), filename='Event.ics') + message.attach(data=open('image.png', 'rb'), filename='image.png', content_disposition='inline') Use templates: diff --git a/docs/index.rst b/docs/index.rst index 21702d8..a256109 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,7 +11,7 @@ Modern email handling in python. text=T("Build passed: {{ project_name }} ..."), subject=T("Passed: {{ project_name }}#{{ build_id }}"), mail_from=("CI", "ci@mycompany.com")) - m.attach(filename="icon.png", content_disposition="inline", data=open("icon.png")) + m.attach(filename="icon.png", content_disposition="inline", data=open("icon.png", "rb")) response = m.send(render={"project_name": "user/project1", "build_id": 121}, to='somebody@mycompany.com', smtp={"host":"mx.mycompany.com", "port": 25}) diff --git a/docs/transformations.rst b/docs/transformations.rst index 168b470..819d2bd 100644 --- a/docs/transformations.rst +++ b/docs/transformations.rst @@ -16,7 +16,7 @@ Code example to make images inline: .. code-block:: python >>> message = emails.Message(html="") - >>> message.attach(filename='promo.png', data=open('promo.png')) + >>> message.attach(filename='promo.png', data=open('promo.png', 'rb')) >>> message.attachments['promo.png'].is_inline = True >>> message.transformer.synchronize_inline_images() >>> message.transformer.save() @@ -41,7 +41,7 @@ Load from zipfile or directory: .. code-block:: python - message = emails.loader.from_zipfile(open('design_pack.zip')) + message = emails.loader.from_zipfile(open('design_pack.zip', 'rb')) message = emails.loader.from_directory('/home/user/design_pack') Zipfile and directory loaders require at least one html file (with "html" extension).