-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (40 loc) · 992 Bytes
/
main.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
package main
import (
"./modules"
"github.com/robfig/cron"
"log"
)
func main() {
path := "./config.json"
data := modules.ConfigInformation{
Receiver: []string{"To Emails"},
Sender: "From",
ServerHost: "Email server host",
ServerPort: 25,
APICredit: "Email passwd",
TaskSend: "0 0 0 * * *",
TaskCheck: "0 0 * * * *",
TaskTry: "*/5 * * * * ?"}
if data.ReadJSON(path) != nil {
data.WriteJSON(path)
log.Fatal("Please set the config.json file for your email service.")
}
timer := cron.New()
l := modules.LocalInfo{IPs: []string{"0.0.0.0"}}
e := modules.EmailInfo{
LocalInfo: &l,
Receiver: data.Receiver,
Sender: data.Sender,
ServerHost: data.ServerHost,
ServerPort: data.ServerPort,
APICredit: data.APICredit,
TaskSend: data.TaskSend,
TaskCheck: data.TaskCheck,
TaskTry: data.TaskTry,
Message: ""}
timer.AddJob(data.TaskCheck, &l)
timer.AddJob(data.TaskSend, e)
timer.Start()
defer timer.Stop()
select {}
}