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:
33
chasquid.go
33
chasquid.go
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user