Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Add support for custom SMTP HELO hostname (for FQDNS)

Kailash Nadh9a88c2ed7b69
diff --git a/config.toml.sample b/config.toml.sample
index 9b29c700..535edd93 100644
--- a/config.toml.sample
+++ b/config.toml.sample
@@ -84,6 +84,11 @@ max_idle = 10
username = "xxxxx"
password = ""
+ # Optional. Some SMTP servers require a FQDN in the hostname.
+ # By default, HELLOs go with "localhost". Set this if a custom
+ # hostname should be used.
+ hello_hostname = ""
+
# Maximum time (milliseconds) to wait per e-mail push.
send_timeout = 5000
diff --git a/go.mod b/go.mod
index bb829e47..aa594c99 100644
--- a/go.mod
+++ b/go.mod
@@ -30,4 +30,6 @@ require (
gopkg.in/volatiletech/null.v6 v6.0.0-20170828023728-0bef4e07ae1b
)
+replace github.com/jordan-wright/email => github.com/knadh/email v0.0.0-20200206100304-6d2c7064c2e8
+
go 1.13
diff --git a/go.sum b/go.sum
index 10966391..65e59acd 100644
--- a/go.sum
+++ b/go.sum
@@ -24,6 +24,10 @@ github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/jordan-wright/email v0.0.0-20181027021455-480bedc4908b h1:veTPVnbkOijplSJVywDYKDRPoZEN39kfuMDzzRKP0FA=
github.com/jordan-wright/email v0.0.0-20181027021455-480bedc4908b/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A=
+github.com/knadh/email v0.0.0-20181027021455-480bedc4908b h1:EJPKWXCv9G08Gs5KWjUP8PKj8trrRsLO8B90KZycApE=
+github.com/knadh/email v0.0.0-20181027021455-480bedc4908b/go.mod h1:xqJp94kA9qz2ffXuDJueBN+K6MP5BfEGmbIHR8MDJOo=
+github.com/knadh/email v0.0.0-20200206100304-6d2c7064c2e8 h1:HVq7nA5uWjpo93WsWjva1YIBuQrr8UkWQEUbzg1DX+E=
+github.com/knadh/email v0.0.0-20200206100304-6d2c7064c2e8/go.mod h1:Fy2gCFfZhay8jplf/Csj6cyH/oshQTkLQYZbKkcV+SY=
github.com/knadh/goyesql v1.1.1 h1:iQLgsjYI/zC417DhmZYxmJgWmCHhtV4fho5QazWL/1g=
github.com/knadh/goyesql v1.1.1/go.mod h1:W0tSzU8l7lYH1Fihj+bdQzkzOwvirrsMNHwkuY22qoY=
github.com/knadh/goyesql v2.0.0+incompatible h1:hJFJrU8kaiLmvYt9I/1k1AB7q+qRhHs/afzTfQ3eGqk=
diff --git a/messenger/emailer.go b/messenger/emailer.go
index 80df9c37..36f12911 100644
--- a/messenger/emailer.go
+++ b/messenger/emailer.go
@@ -13,14 +13,15 @@ const emName = "email"
// Server represents an SMTP server's credentials.
type Server struct {
- Name string
- Host string `koanf:"host"`
- Port int `koanf:"port"`
- AuthProtocol string `koanf:"auth_protocol"`
- Username string `koanf:"username"`
- Password string `koanf:"password"`
- SendTimeout time.Duration `koanf:"send_timeout"`
- MaxConns int `koanf:"max_conns"`
+ Name string
+ Host string `koanf:"host"`
+ Port int `koanf:"port"`
+ AuthProtocol string `koanf:"auth_protocol"`
+ Username string `koanf:"username"`
+ Password string `koanf:"password"`
+ HelloHostname string `koanf:"hello_hostname"`
+ SendTimeout time.Duration `koanf:"send_timeout"`
+ MaxConns int `koanf:"max_conns"`
mailer *email.Pool
}
@@ -52,6 +53,11 @@ func NewEmailer(srv ...Server) (Messenger, error) {
return nil, err
}
+ // Optional SMTP HELLO hostname.
+ if server.HelloHostname != "" {
+ pool.SetHelloHostname(server.HelloHostname)
+ }
+
s.mailer = pool
e.servers[s.Name] = &s
e.serverNames = append(e.serverNames, s.Name)