mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
in smtpserver, accept delivery to postmaster@<hostname>, and also postmaster@ addresses for domains that don't have a postmaster address configured.
This commit is contained in:
@ -22,8 +22,21 @@ func FindAccount(localpart smtp.Localpart, domain dns.Domain, allowPostmaster bo
|
||||
if strings.EqualFold(string(localpart), "postmaster") {
|
||||
localpart = "postmaster"
|
||||
}
|
||||
var zerodomain dns.Domain
|
||||
if localpart == "postmaster" && domain == zerodomain {
|
||||
|
||||
postmasterDomain := func() bool {
|
||||
var zerodomain dns.Domain
|
||||
if domain == zerodomain || domain == Conf.Static.HostnameDomain {
|
||||
return true
|
||||
}
|
||||
for _, l := range Conf.Static.Listeners {
|
||||
if l.SMTP.Enabled && domain == l.HostnameDomain {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if localpart == "postmaster" && postmasterDomain() {
|
||||
if !allowPostmaster {
|
||||
return "", "", config.Destination{}, ErrAccountNotFound
|
||||
}
|
||||
@ -44,6 +57,9 @@ func FindAccount(localpart smtp.Localpart, domain dns.Domain, allowPostmaster bo
|
||||
accAddr, ok := Conf.AccountDestination(canonical)
|
||||
if !ok {
|
||||
if accAddr, ok = Conf.AccountDestination("@" + domain.Name()); !ok {
|
||||
if localpart == "postmaster" && allowPostmaster {
|
||||
return Conf.Static.Postmaster.Account, "postmaster", config.Destination{Mailbox: Conf.Static.Postmaster.Mailbox}, nil
|
||||
}
|
||||
return "", "", config.Destination{}, ErrAccountNotFound
|
||||
}
|
||||
canonical = "@" + domain.Name()
|
||||
|
Reference in New Issue
Block a user