mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
make it harder to forget to set smtputf8 on message.Composer
we should do better: first gather all headers, and only write it when we start on the body, and then calculate smtputf8 ourselves.
This commit is contained in:
@ -32,10 +32,14 @@ type Composer struct {
|
||||
|
||||
// NewComposer initializes a new composer with a buffered writer around w, and
|
||||
// with a maximum message size if maxSize is greater than zero.
|
||||
//
|
||||
// smtputf8 must be set when the message must be delivered with smtputf8: if any
|
||||
// email address localpart has non-ascii (utf-8).
|
||||
//
|
||||
// Operations on a Composer do not return an error. Caller must use recover() to
|
||||
// catch ErrCompose and optionally ErrMessageSize errors.
|
||||
func NewComposer(w io.Writer, maxSize int64) *Composer {
|
||||
return &Composer{bw: bufio.NewWriter(w), maxSize: maxSize}
|
||||
func NewComposer(w io.Writer, maxSize int64, smtputf8 bool) *Composer {
|
||||
return &Composer{bw: bufio.NewWriter(w), maxSize: maxSize, SMTPUTF8: smtputf8, Has8bit: smtputf8}
|
||||
}
|
||||
|
||||
// Write implements io.Writer, but calls panic (that is handled higher up) on
|
||||
|
@ -91,7 +91,8 @@ func ExampleComposer() {
|
||||
var b bytes.Buffer
|
||||
|
||||
// NewComposer. Keep in mind that operations on a Composer will panic on error.
|
||||
xc := message.NewComposer(&b, 10*1024*1024)
|
||||
const smtputf8 = false
|
||||
xc := message.NewComposer(&b, 10*1024*1024, smtputf8)
|
||||
|
||||
// Catch and handle errors when composing.
|
||||
defer func() {
|
||||
|
Reference in New Issue
Block a user