emersion / go-smtp

📤 An SMTP client & server library written in Go
MIT License
1.72k stars 217 forks source link

RFC 3030 (CHUNKING, BINARYMIME) support #81

Open foxcpp opened 4 years ago

foxcpp commented 4 years ago

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

emersion commented 4 years ago

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

norguhtar commented 3 years ago

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

foxcpp commented 3 years ago

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

emersion commented 3 years ago

Looks like a good idea to me too.

norguhtar commented 3 years ago

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

emersion commented 5 months ago

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)?

norguhtar commented 5 months ago

I'm send really big data. For work purpose i'm need send 8Gb data file. And use really big chunk size. I think usefull size 1Megabyte.