1
0
mirror of https://git.keinpfusch.net/loweel/zangtumb synced 2024-12-19 08:12:46 +01:00
zangtumb/zangtumb.go

69 lines
1.5 KiB
Go
Raw Normal View History

2020-10-08 22:36:17 +02:00
package main
import (
"log"
"os"
"zangtumb/smtpd"
)
var ZangSmtpServer *smtpd.Server
var KeyFile, CrtFile, ServerName, ListenAddr string
const AppName = "ZangTumb"
func init() {
ZangSmtpServer = new(smtpd.Server)
KeyFile = os.Getenv("KEYFILE")
log.Println("KeyFile: ", KeyFile)
CrtFile = os.Getenv("CERTFILE")
log.Println("CrtFile: ", CrtFile)
ServerName = os.Getenv("DOMAINNAME")
log.Println("ServerName: ", ServerName)
ListenAddr = os.Getenv("LISTEN")
log.Println("ListenAddr: ", ListenAddr)
ZangSmtpServer.AuthRequired = false
ZangSmtpServer.Hostname = ServerName
ZangSmtpServer.MaxRcpt = SmtpBackend.MaxRecipients
if ZangSmtpServer.MaxRcpt == 0 {
ZangSmtpServer.MaxRcpt = 1
log.Println("No recipients, setting MaxRcpt to 1")
} else {
log.Println("MaxRcpt: ", ZangSmtpServer.MaxRcpt)
}
if os.Getenv("USETLS") == "true" {
2021-07-31 15:00:12 +02:00
log.Println("Preparing TLS Keys")
ZMakecert()
2020-10-08 22:36:17 +02:00
ZangSmtpServer.ConfigureTLS(CrtFile, KeyFile)
ZangSmtpServer.TLSListener = false
ZangSmtpServer.TLSRequired = true
log.Println("Using TLS")
} else {
ZangSmtpServer.TLSListener = false
ZangSmtpServer.TLSRequired = false
log.Println("WARNING: NOT Using TLS")
}
2021-07-31 15:00:12 +02:00
log.Println("Ready to start the server.")
2020-10-08 22:36:17 +02:00
}
func main() {
log.Println("Starting the server....")
defer log.Println("Shutting down the server")
if err := smtpd.ListenAndServe(ListenAddr, mailHandler, handlerRcpt, AppName, ServerName, ZangSmtpServer); err != nil {
2020-10-08 22:36:17 +02:00
log.Panicln("Ops. Something went wrong: ", err.Error())
}
}