/* diodemail - send-only smtp server * Copyright (c) 2024 Gnarwhal * * This file is part of SSHare. * * SSHare is free software: you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software Foundation, * either version 3 of the License, or (at your option) any later version. * * SSHare is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * SSHare. If not, see . */ package main import ( "log" "flag" "crypto/tls" "forge.monodon.me/Gnarwhal/diodemail/smtp" ) func main() { var cert_path string flag.StringVar(&cert_path, "config", "/etc/diodemail/config.json", "Path to config file") flag.Parse() config, err := LoadConfig(cert_path) if err != nil { log.Fatal(err) } var plain_config *smtp.PlainConfig if config.Plain.Enabled { plain_config = &smtp.PlainConfig { config.Plain.Port, } } var tls_config *smtp.TLSConfig if config.TLS.Enabled { certificate, err := tls.LoadX509KeyPair( config.TLS.CertPath, config.TLS.PrivateKeyPath, ) if err != nil { log.Println(err) } else { tls_config = &smtp.TLSConfig { config.TLS.Port, tls.Config{Certificates: []tls.Certificate{certificate}}, } } } err = smtp.Run( config.Host, plain_config, tls_config, ) if err != nil { log.Fatal(err) } }