mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 09:54:40 +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:
@ -875,7 +875,15 @@ Period: %s - %s UTC
|
||||
}
|
||||
|
||||
func composeAggregateReport(ctx context.Context, log mlog.Log, mf *os.File, fromAddr smtp.Address, recipients []message.NameAddress, subject, text, filename string, reportXMLGzipFile *os.File) (msgPrefix string, has8bit, smtputf8 bool, messageID string, rerr error) {
|
||||
xc := message.NewComposer(mf, 100*1024*1024)
|
||||
// We only use smtputf8 if we have to, with a utf-8 localpart. For IDNA, we use ASCII domains.
|
||||
smtputf8 = fromAddr.Localpart.IsInternational()
|
||||
for _, r := range recipients {
|
||||
if smtputf8 {
|
||||
smtputf8 = r.Address.Localpart.IsInternational()
|
||||
break
|
||||
}
|
||||
}
|
||||
xc := message.NewComposer(mf, 100*1024*1024, smtputf8)
|
||||
defer func() {
|
||||
x := recover()
|
||||
if x == nil {
|
||||
@ -888,14 +896,6 @@ func composeAggregateReport(ctx context.Context, log mlog.Log, mf *os.File, from
|
||||
panic(x)
|
||||
}()
|
||||
|
||||
// We only use smtputf8 if we have to, with a utf-8 localpart. For IDNA, we use ASCII domains.
|
||||
for _, a := range recipients {
|
||||
if a.Address.Localpart.IsInternational() {
|
||||
xc.SMTPUTF8 = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
xc.HeaderAddrs("From", []message.NameAddress{{Address: fromAddr}})
|
||||
xc.HeaderAddrs("To", recipients)
|
||||
xc.Subject(subject)
|
||||
@ -1015,7 +1015,15 @@ Submitting-URI: %s
|
||||
}
|
||||
|
||||
func composeErrorReport(ctx context.Context, log mlog.Log, mf *os.File, fromAddr smtp.Address, recipients []message.NameAddress, subject, text string) (msgPrefix string, has8bit, smtputf8 bool, messageID string, rerr error) {
|
||||
xc := message.NewComposer(mf, 100*1024*1024)
|
||||
// We only use smtputf8 if we have to, with a utf-8 localpart. For IDNA, we use ASCII domains.
|
||||
smtputf8 = fromAddr.Localpart.IsInternational()
|
||||
for _, r := range recipients {
|
||||
if smtputf8 {
|
||||
smtputf8 = r.Address.Localpart.IsInternational()
|
||||
break
|
||||
}
|
||||
}
|
||||
xc := message.NewComposer(mf, 100*1024*1024, smtputf8)
|
||||
defer func() {
|
||||
x := recover()
|
||||
if x == nil {
|
||||
@ -1028,14 +1036,6 @@ func composeErrorReport(ctx context.Context, log mlog.Log, mf *os.File, fromAddr
|
||||
panic(x)
|
||||
}()
|
||||
|
||||
// We only use smtputf8 if we have to, with a utf-8 localpart. For IDNA, we use ASCII domains.
|
||||
for _, a := range recipients {
|
||||
if a.Address.Localpart.IsInternational() {
|
||||
xc.SMTPUTF8 = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
xc.HeaderAddrs("From", []message.NameAddress{{Address: fromAddr}})
|
||||
xc.HeaderAddrs("To", recipients)
|
||||
xc.Header("Subject", subject)
|
||||
|
Reference in New Issue
Block a user