forked from mistralmail/mistralmail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (42 loc) · 999 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
46
47
48
49
50
51
52
53
package main
import (
"os"
"os/signal"
"syscall"
"github.com/gopistolet/gopistolet/handlers"
"github.com/gopistolet/gopistolet/helpers"
"github.com/gopistolet/gopistolet/log"
"github.com/gopistolet/smtp/mta"
)
var c mta.Config
func main() {
log.Timestamp()
log.SetLevel(log.DebugLevel)
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, os.Interrupt, syscall.SIGTERM)
nixspamBlacklist, err := helpers.NewNixspam()
if err != nil {
log.Warnln("Couldn't create Nixspam Blacklist instance: ", err)
}
log.Println("GoPistolet at your service!")
// Default config
c = mta.Config{
Hostname: "localhost",
Port: 25,
Blacklist: nixspamBlacklist,
}
// Load config from JSON file
err = helpers.DecodeFile("config.json", &c)
if err != nil {
log.Warnln(err, "- Using default configuration instead.")
}
mta := mta.NewDefault(c, handlers.LoadHandlers(&c))
go func() {
<-sigc
mta.Stop()
}()
err = mta.ListenAndServe()
if err != nil {
log.Errorln(err)
}
}