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:
Mechiel Lukkien
2024-03-16 20:54:10 +01:00
parent 8b2c97808d
commit cef83341e5
5 changed files with 37 additions and 34 deletions

View File

@ -366,8 +366,6 @@ func (w Webmail) MessageSubmit(ctx context.Context, m SubmitMessage) {
xcheckf(ctx, err, "checking send limit")
})
has8bit := false // We update this later on.
// We only use smtputf8 if we have to, with a utf-8 localpart. For IDNA, we use ASCII domains.
smtputf8 := false
for _, a := range recipients {
@ -387,7 +385,7 @@ func (w Webmail) MessageSubmit(ctx context.Context, m SubmitMessage) {
defer store.CloseRemoveTempFile(log, dataFile, "message to submit")
// If writing to the message file fails, we abort immediately.
xc := message.NewComposer(dataFile, w.maxMessageSize)
xc := message.NewComposer(dataFile, w.maxMessageSize, smtputf8)
defer func() {
x := recover()
if x == nil {
@ -643,7 +641,7 @@ func (w Webmail) MessageSubmit(ctx context.Context, m SubmitMessage) {
Localpart: rcpt.Localpart,
IPDomain: dns.IPDomain{Domain: rcpt.Domain},
}
qm := queue.MakeMsg(fromPath, toPath, has8bit, smtputf8, msgSize, messageID, []byte(rcptMsgPrefix), m.RequireTLS, now)
qm := queue.MakeMsg(fromPath, toPath, xc.Has8bit, xc.SMTPUTF8, msgSize, messageID, []byte(rcptMsgPrefix), m.RequireTLS, now)
if m.FutureRelease != nil {
ival := time.Until(*m.FutureRelease)
if ival < 0 {