1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-19 14:57:04 +00:00

WIP: Add smarthost support

WORK IN PROGRESS -- WORK IN PROGRESS -- WORK IN PROGRESS

This patch adds support for delivering mail via a smarthost.

In this mode, all accepted mail gets delivered through an SMTP
connection to a specific host, statically configured.
This commit is contained in:
Alberto Bertogli
2020-09-22 01:52:44 +01:00
parent 4efe8db947
commit 0f2ffc8ff5
22 changed files with 633 additions and 19 deletions

View File

@@ -12,6 +12,7 @@ import (
"io/ioutil"
"math/rand"
"net"
"net/url"
"os"
"os/signal"
"path/filepath"
@@ -160,16 +161,30 @@ func main() {
}
go stsCache.PeriodicallyRefresh(context.Background())
localC := &courier.MDA{
Binary: conf.MailDeliveryAgentBin,
Args: conf.MailDeliveryAgentArgs,
Timeout: 30 * time.Second,
}
remoteC := &courier.SMTP{
HelloDomain: conf.Hostname,
Dinfo: dinfo,
STSCache: stsCache,
var localC, remoteC courier.Courier
if conf.SmarthostUrl != "" {
smurl, err := url.Parse(conf.SmarthostUrl)
if err != nil {
log.Fatalf("Invalid smarthost url: %v", err)
}
remoteC = &courier.SmartHost{
HelloDomain: conf.Hostname,
URL: *smurl,
}
localC = remoteC
} else {
localC = &courier.MDA{
Binary: conf.MailDeliveryAgentBin,
Args: conf.MailDeliveryAgentArgs,
Timeout: 30 * time.Second,
}
remoteC = &courier.SMTP{
HelloDomain: conf.Hostname,
Dinfo: dinfo,
STSCache: stsCache,
}
}
s.InitQueue(conf.DataDir+"/queue", localC, remoteC)
// Load the addresses and listeners.