-
Notifications
You must be signed in to change notification settings - Fork 0
/
senderPolicy.go
36 lines (32 loc) · 1.15 KB
/
senderPolicy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package connect
import "encoding/json"
type SenderPolicyOptions struct {
AuthenticationRequired bool `json:"authenticationRequired"` // Require sender authentication for local domains
AntiSpoofingEnabled bool `json:"antiSpoofingEnabled"` // Is Antispoofing enabled
IPWhiteList OptionalEntity `json:"IPWhiteList"` // Trusted senders (Not chceked by anti-spoofing)
}
// SenderPolicyGet - Obtain Sender Policy options.
// Return
// options - current sender options
func (s *ServerConnection) SenderPolicyGet() (*SenderPolicyOptions, error) {
data, err := s.CallRaw("SenderPolicy.get", nil)
if err != nil {
return nil, err
}
options := struct {
Result struct {
Options SenderPolicyOptions `json:"options"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &options)
return &options.Result.Options, err
}
// SenderPolicySet - Set Sender Policy options.
// options - options to be updated
func (s *ServerConnection) SenderPolicySet(options SenderPolicyOptions) error {
params := struct {
Options SenderPolicyOptions `json:"options"`
}{options}
_, err := s.CallRaw("SenderPolicy.set", params)
return err
}