mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 08:23:48 +03:00
ensure senderaccount is always set for messages in queue
before, the smtpserver that queued a dsn would set an empty senderaccount, which was interpreted in a few places as the globally configured postmaster cacount. the empty senderaccount would be used by the smtpserver that queued a dsn with null return path. we now set the postmaster account when we add a message to the queue. more code in the queue pretty much needs a non-empty senderaccount, such as the filters when listing, and the suppression list.
This commit is contained in:
parent
6e7f15e0e4
commit
e2924af8d2
3 changed files with 21 additions and 25 deletions
|
@ -204,11 +204,9 @@ func cleanupHookRetiredSingle(log mlog.Log) {
|
||||||
|
|
||||||
func hookRetiredKeep(account string) time.Duration {
|
func hookRetiredKeep(account string) time.Duration {
|
||||||
keep := 24 * 7 * time.Hour
|
keep := 24 * 7 * time.Hour
|
||||||
if account != "" {
|
accConf, ok := mox.Conf.Account(account)
|
||||||
accConf, ok := mox.Conf.Account(account)
|
if ok {
|
||||||
if ok {
|
keep = accConf.KeepRetiredWebhookPeriod
|
||||||
keep = accConf.KeepRetiredWebhookPeriod
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return keep
|
return keep
|
||||||
}
|
}
|
||||||
|
|
|
@ -1366,26 +1366,24 @@ func deliver(log mlog.Log, resolver dns.Resolver, m0 Msg) {
|
||||||
var remoteMTA dsn.NameIP // Zero value, will not be included in DSN. ../rfc/3464:1027
|
var remoteMTA dsn.NameIP // Zero value, will not be included in DSN. ../rfc/3464:1027
|
||||||
|
|
||||||
// Check if recipient is on suppression list. If so, fail delivery.
|
// Check if recipient is on suppression list. If so, fail delivery.
|
||||||
if m0.SenderAccount != "" {
|
path := smtp.Path{Localpart: m0.RecipientLocalpart, IPDomain: m0.RecipientDomain}
|
||||||
path := smtp.Path{Localpart: m0.RecipientLocalpart, IPDomain: m0.RecipientDomain}
|
baseAddr := baseAddress(path).XString(true)
|
||||||
baseAddr := baseAddress(path).XString(true)
|
qsup := bstore.QueryTx[webapi.Suppression](xtx)
|
||||||
qsup := bstore.QueryTx[webapi.Suppression](xtx)
|
qsup.FilterNonzero(webapi.Suppression{Account: m0.SenderAccount, BaseAddress: baseAddr})
|
||||||
qsup.FilterNonzero(webapi.Suppression{Account: m0.SenderAccount, BaseAddress: baseAddr})
|
exists, err := qsup.Exists()
|
||||||
exists, err := qsup.Exists()
|
if err != nil || exists {
|
||||||
if err != nil || exists {
|
if err != nil {
|
||||||
if err != nil {
|
qlog.Errorx("checking whether recipient address is in suppression list", err)
|
||||||
qlog.Errorx("checking whether recipient address is in suppression list", err)
|
} else {
|
||||||
} else {
|
err := fmt.Errorf("not delivering to recipient address %s: %w", path.XString(true), errSuppressed)
|
||||||
err := fmt.Errorf("not delivering to recipient address %s: %w", path.XString(true), errSuppressed)
|
err = smtpclient.Error{Permanent: true, Err: err}
|
||||||
err = smtpclient.Error{Permanent: true, Err: err}
|
failMsgsTx(qlog, xtx, []*Msg{&m0}, m0.DialedIPs, backoff, remoteMTA, err)
|
||||||
failMsgsTx(qlog, xtx, []*Msg{&m0}, m0.DialedIPs, backoff, remoteMTA, err)
|
|
||||||
}
|
|
||||||
err = xtx.Commit()
|
|
||||||
qlog.Check(err, "commit processing failure to deliver messages")
|
|
||||||
xtx = nil
|
|
||||||
kick()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
err = xtx.Commit()
|
||||||
|
qlog.Check(err, "commit processing failure to deliver messages")
|
||||||
|
xtx = nil
|
||||||
|
kick()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveTransport := func(mm Msg) (string, config.Transport, bool) {
|
resolveTransport := func(mm Msg) (string, config.Transport, bool) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ func queueDSN(ctx context.Context, log mlog.Log, c *conn, rcptTo smtp.Path, m ds
|
||||||
}
|
}
|
||||||
qm := queue.MakeMsg(smtp.Path{}, rcptTo, has8bit, smtputf8, int64(len(buf)), m.MessageID, nil, reqTLS, time.Now(), m.Subject)
|
qm := queue.MakeMsg(smtp.Path{}, rcptTo, has8bit, smtputf8, int64(len(buf)), m.MessageID, nil, reqTLS, time.Now(), m.Subject)
|
||||||
qm.DSNUTF8 = bufUTF8
|
qm.DSNUTF8 = bufUTF8
|
||||||
if err := queue.Add(ctx, c.log, "", f, qm); err != nil {
|
if err := queue.Add(ctx, c.log, mox.Conf.Static.Postmaster.Account, f, qm); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue