mirror of
https://git.keinpfusch.net/loweel/zangtumb
synced 2024-12-18 13:18:37 +01:00
69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
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" {
|
|
log.Println("Preparing TLS Keys")
|
|
ZMakecert()
|
|
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")
|
|
}
|
|
|
|
|
|
|
|
log.Println("Ready to start the server.")
|
|
|
|
}
|
|
|
|
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 {
|
|
log.Panicln("Ops. Something went wrong: ", err.Error())
|
|
}
|
|
}
|