diff --git a/email.go b/email.go index fa9e9b5..7e0a6c2 100644 --- a/email.go +++ b/email.go @@ -154,6 +154,33 @@ func (c *UserContext) UpdateEmailAccount(emailAccount EmailAccount) error { return nil } +// UseInternalMailHandler tells the server to use the local mail handler for the given domain. If this is enabled, other +// domains on the server that email this domain will use the server's local mail handler to deliver the email, rather +// than looking up the domain's MX records. This is fine if your email is being hosted on the same server, but not +// otherwise. +func (c *UserContext) UseInternalMailHandler(domain string, enable bool) error { + var response apiGenericResponse + + body := url.Values{} + body.Set("domain", domain) + + if enable { + body.Set("internal", "yes") + } else { + body.Set("internal", "no") + } + + if _, err := c.makeRequestOld(http.MethodPost, "API_DNS_MX?action=internal", body, &response); err != nil { + return err + } + + if response.Success != "Option Saved" { + return fmt.Errorf("failed to set internal mail handler for %v: %v", domain, response.Result) + } + + return nil +} + // VerifyEmailAccount (user) accepts the full email address as well as the password for the account. If the credentials aren't correct, an error will be returned. func (c *UserContext) VerifyEmailAccount(address string, password string) error { var response apiGenericResponse diff --git a/go.mod b/go.mod index 310a375..f7a1358 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,5 @@ go 1.22 require ( github.com/goccy/go-json v0.10.3 github.com/google/go-querystring v1.1.0 - github.com/spf13/cast v1.6.0 - golang.org/x/text v0.15.0 + github.com/spf13/cast v1.7.0 ) diff --git a/go.sum b/go.sum index e907265..753913c 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,6 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= +github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=