python / python/cpython

Support chunk sending in `smtplib`

Open
#135,952 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

performance stdlib topic-email type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

smtplib.SMTP currently has the method data(msg : Union[bytes, str]) to send the message which takes the entire serialized rfc822 message as bytes or str. Email messages can be pretty large -- 10M or more. So it would be nice to be able to send the message in chunks without having to bring it all into the python heap at once. I have a proof-of-concept of this
that adds a parameter data(msg : bytes, last : bool) that I am using in Koukan my mta project.

smtp.data(b'hello\r\n', last=False)
smtp.data(b'world!\r\n', last=True)

I wanted to see if there was any interest in merging this. Building on this, I have another patch to add support for rfc3030 CHUNKING/BDAT which is maybe a separate discussion but if we extend the api here, it ought to be able to support both dotstuff and bdat transparently.

In parallel with this, I am trying to make the corresponding change to aiosmtpd

Has this already been discussed elsewhere?

https://discuss.python.org/t/smtplib-chunked-sending/96804

Links to previous discussion of this feature:

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at smtplib.SMTP.data and review the linked chunked-data proof of concept, then read the linked Python discussion. Resolve the API and its relationship to RFC 3030 CHUNKING/BDAT and dot-stuffing before implementation; done means an agreed chunk-sending design is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.