package main import ( "fmt" "log" "net/http" "os" "strconv" "github.com/tsawler/toolbox" ) const webPort = "80" type Config struct { Host string Port int UserName string Password string Encryption string Tools toolbox.Tools Mailer Mail } func main() { app := Config{ Mailer: createMail(), } log.Printf("Starting mail service on port %s\n", webPort) // define http server srv := &http.Server{ Addr: fmt.Sprintf(":%s", webPort), Handler: app.routes(), } err := srv.ListenAndServe() if err != nil { log.Panic(err) } } func createMail() Mail { port, _ := strconv.Atoi(os.Getenv("MAIL_PORT")) return Mail{ Domain: os.Getenv("MAIL_DOMAIN"), Host: os.Getenv("MAIL_HOST"), Port: port, Username: os.Getenv("MAIL_USERNAME"), Password: os.Getenv("MAIL_PASSWORD"), Encryption: os.Getenv("MAIL_ENCRYPTION"), FromName: os.Getenv("FROM_NAME"), FromAddr: os.Getenv("FROM_ADDR"), } }