Skip to content

Provide an API to stream messages, instead of loading them into memory #20

Open
@manuco

Description

@manuco

Today, the aiosmtplib only accepts email body as string or bytes. It means that the mail should be completly loaded in memory before begining to send it.

With asyncio, it is very easy to work with streams (generated on the fly, read from files, pipes, sockets, etc). Moreover, if we want to send more that a few emails, we should either send them sequentially or load all of them in memory. In either case, we loose one of the feature of async programmming.

It would be nice to support email bodies as something else than just static buffers (string or bytes). Have a look at the aiohttp multipart module (http://aiohttp.readthedocs.io/en/stable/multipart.html). It enables to build a MIME Multipart body by attaching string, bytes, but also HTTP Responses, streams, etc. The content is serialized on the fly when using the object, and can be streamed to a socket or the standard output.

It would be nice to allow a streamable object as a message body, allowing not to load the content completly into memory while sending it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚀 featuresomething that would be nice

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions