return smtp response/error correctly in more cases

This commit is contained in:
Mechiel Lukkien 2024-04-14 17:28:00 +02:00
parent 4012b72d96
commit 12e6975aa7
No known key found for this signature in database

View file

@ -708,14 +708,18 @@ func deliverHost(log mlog.Log, resolver dns.Resolver, dialer smtpclient.Dialer,
} }
resps, err := sc.DeliverMultiple(ctx, mailFrom, rcpts, size, msg, has8bit, smtputf8, m0.RequireTLS != nil && *m0.RequireTLS) resps, err := sc.DeliverMultiple(ctx, mailFrom, rcpts, size, msg, has8bit, smtputf8, m0.RequireTLS != nil && *m0.RequireTLS)
if err != nil && len(resps) == len(msgResps) { if err != nil && (len(resps) == 0 && n == len(msgResps) || len(resps) == len(msgResps)) {
// If error and it applies to all recipients, return a single error. // If error and it applies to all recipients, return a single error.
return deliverResult{err: inspectError(err)} return deliverResult{err: inspectError(err)}
} }
var ntodo []*msgResp var ntodo []*msgResp
for i, mr := range todo[:n] { for i, mr := range todo[:n] {
if err != nil { if err != nil {
mr.resp = smtpclient.Response{Err: err} if cerr, ok := err.(smtpclient.Error); ok {
mr.resp = smtpclient.Response(cerr)
} else {
mr.resp = smtpclient.Response{Err: err}
}
failed = append(failed, mr) failed = append(failed, mr)
} else if i > 0 && (resps[i].Code == smtp.C452StorageFull || resps[i].Code == smtp.C552MailboxFull) { } else if i > 0 && (resps[i].Code == smtp.C452StorageFull || resps[i].Code == smtp.C552MailboxFull) {
ntodo = append(ntodo, mr) ntodo = append(ntodo, mr)