Added support for sending with relay hosts

This commit is contained in:
Niels Bouma
2023-05-10 19:33:05 +00:00
committed by Aine
parent 84102d5b5b
commit ee8d8680ac
7 changed files with 153 additions and 36 deletions

View File

@@ -29,6 +29,7 @@ type Config struct {
MaxSize int
Bot matrixbot
Callers []Caller
Relay RelayConfig
}
type TLSConfig struct {
@@ -40,6 +41,13 @@ type TLSConfig struct {
Mu sync.Mutex
}
type RelayConfig struct {
Host string
Port string
Usename string
Password string
}
type Manager struct {
log *logger.Logger
bot matrixbot
@@ -71,10 +79,14 @@ type Caller interface {
// NewManager creates new SMTP server manager
func NewManager(cfg *Config) *Manager {
log := logger.New("smtp.", cfg.LogLevel)
smtpClient := newClient(&cfg.Relay, log)
mailsrv := &mailServer{
log: log,
bot: cfg.Bot,
domains: cfg.Domains,
log: log,
bot: cfg.Bot,
domains: cfg.Domains,
mailSender: smtpClient,
}
for _, caller := range cfg.Callers {
caller.SetSendmail(mailsrv.SendEmail)