-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmail.go
101 lines (77 loc) · 2.04 KB
/
mail.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package maestropanel
import (
"encoding/json"
)
type MailBox struct {
Account string `json:"account"`
Password string `json:"password"`
Quota int32 `json:"quota"`
Redirect bool `json:"redirect"`
Remail string `json:"remail"`
DisplayName string `json:"displayname"`
}
type GetMailListResult struct {
Result
Details ExportPostOffice
}
type ExportPostOffice struct {
Name string
Quota int32
Accounts []Account
}
type Mail struct {
mp MaestroPanel
}
func (m *Mail) AddMailBox(mailBox MailBox) (result DomainExecutionResult, err error) {
result = DomainExecutionResult{}
response, err := m.mp.writeData(addMailBoxAction.Method, m.mp.getURL(addMailBoxAction), mailBox)
if err == nil {
json.Unmarshal(response, &result)
}
return
}
func (m *Mail) DeleteMailBox(domainName string, account string) (result DomainExecutionResult, err error) {
result = DomainExecutionResult{}
extra := struct {
Name string `json:"name"`
Account string `json:"account"`
}{
domainName,
account,
}
response, err := m.mp.writeData(deleteMailBoxAction.Method, m.mp.getURL(deleteMailBoxAction), extra)
if err == nil {
json.Unmarshal(response, &result)
}
return
}
func (m *Mail) ChangeMailBoxPassword(domainName string, account string, password string) (result DomainExecutionResult, err error) {
result = DomainExecutionResult{}
extra := struct {
Name string `json:"name"`
Account string `json:"account"`
Password string `json:"newpassword"`
}{
domainName,
account,
password,
}
response, err := m.mp.writeData(changeMailBoxPasswordAction.Method, m.mp.getURL(changeMailBoxPasswordAction), extra)
if err == nil {
json.Unmarshal(response, &result)
}
return
}
func (m *Mail) GetMailList(domainName string) (result GetMailListResult, err error) {
result = GetMailListResult{}
extra := struct {
Name string `json:"name"`
}{
domainName,
}
response, err := m.mp.writeData(getMailListAction.Method, m.mp.getURL(getMailListAction), extra)
if err == nil {
json.Unmarshal(response, &result)
}
return
}