]> src.bluestatic.org Git - mailpopbox.git/blob - mailpopbox.go
Add a systemd unit file for the server.
[mailpopbox.git] / mailpopbox.go
1 package main
2
3 import (
4 "encoding/json"
5 "fmt"
6 "os"
7 )
8
9 func main() {
10 if len(os.Args) != 2 {
11 fmt.Fprintf(os.Stderr, "Usage: %s config.json\n", os.Args[0])
12 os.Exit(1)
13 }
14
15 configFile, err := os.Open(os.Args[1])
16 if err != nil {
17 fmt.Fprintf(os.Stderr, "config file: %s\n", err)
18 os.Exit(2)
19 }
20
21 var config Config
22 if err := json.NewDecoder(configFile).Decode(&config); err != nil {
23 fmt.Fprintf(os.Stderr, "config file: %s\n", err)
24 os.Exit(3)
25 }
26 configFile.Close()
27
28 pop3 := runPOP3Server(config)
29 smtp := runSMTPServer(config)
30
31 select {
32 case err := <-pop3:
33 fmt.Println(err)
34 case err := <-smtp:
35 fmt.Println(err)
36 }
37 }