go-smtp icon indicating copy to clipboard operation
go-smtp copied to clipboard

RFC 3030 (CHUNKING, BINARYMIME) support

Open foxcpp opened this issue 5 years ago • 7 comments

CHUNKING (BDAT) support

Client support: Prefer over DATA if available (avoids the overhead of dot-encoding), require if BODY=BINARYMIME is used (as required by spec). Server support: Transparent support, io.Reader passed to Session.Data reads multiple chunks. Error returned by Data early consumes the current chunk and returns an error without consuming the whole message.

BINARYMIME support

Support BODY=BINARYMIME argument for MAIL command, no other actions required.

Specification: https://tools.ietf.org/html/rfc3030

foxcpp avatar Dec 07 '19 12:12 foxcpp

Server part has been merged in https://github.com/emersion/go-smtp/pull/106. Keeping this issue opened for client support.

emersion avatar Jul 07 '20 12:07 emersion

I'm test BINARYMIME and get error. What i do. Send mail with attachment (10mb size) like this

BDAT 1048576
...
some binary data
....
554 5.0.0 Error: transaction failed, blame it on the weather: smtp: too longer line in input stream

I checked source and found this error generated LimitReader when readLine is got limit. But when we used BDAT and BINARYMIME content not split by lines

From RFC3030

 When the receiver-SMTP accepts a
   MAIL command with the BINARYMIME body-value, it agrees to preserve
   all bits in each octet passed using the BDAT command.  Once a
   receiver-SMTP supporting the BINARYMIME service extension accepts a
   message containing binary material, the receiver-SMTP MUST deliver or
   relay the message in such a way as to preserve all bits in each
   octet.

I can set bigger MaxLineLength but think this not really right solution

norguhtar avatar Mar 18 '21 06:03 norguhtar

Oh well, this is a problem. Perhaps we could disable lineLimitReader while reading a BDAT chunk? Can you make a PR?

foxcpp avatar Mar 18 '21 07:03 foxcpp

Looks like a good idea to me too.

emersion avatar Mar 18 '21 07:03 emersion

Oh well, this is a problem. Perhaps we could disable lineLimitReader while reading a BDAT chunk? Can you make a PR?

Yes. I investigate problem and send PR

norguhtar avatar Mar 18 '21 08:03 norguhtar

What would be a good chunk size for BDAT? Should we only use BDAT when PIPELINING is also available (to avoid having to wait for the server ACK'ing each chunk)?

emersion avatar Apr 15 '24 10:04 emersion