1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00

Allow SMTP config to specify FQDN of sending server

/cc @backba
This commit is contained in:
Harvey Kandola 2019-02-28 12:31:02 +00:00
parent 560f786b8b
commit 2510972a83
3 changed files with 20 additions and 2 deletions

View file

@ -56,5 +56,7 @@ func GetSMTPConfig(s *store.Store) (c smtp.Config) {
c.SkipSSLVerify, _ = strconv.ParseBool(verifySSL) c.SkipSSLVerify, _ = strconv.ParseBool(verifySSL)
c.SkipSSLVerify = true c.SkipSSLVerify = true
c.SenderFQDN, _ = s.Setting.Get("SMTP", "fqdn")
return return
} }

View file

@ -51,6 +51,11 @@ type Config struct {
// SkipSSLVerify allows unverified certificates // SkipSSLVerify allows unverified certificates
SkipSSLVerify bool SkipSSLVerify bool
// SenderFQDN is the sending servers fully qualified domain name
// as some SMTP servers require a value other than localhost.
// e.g. docs.example.org
SenderFQDN string
} }
// Connect returns open connection to server for sending email // Connect returns open connection to server for sending email
@ -71,10 +76,10 @@ func Connect(c Config) (d *mail.Dialer, err error) {
p = base64.StdEncoding.EncodeToString([]byte(p)) p = base64.StdEncoding.EncodeToString([]byte(p))
} }
// basic server // Basic server
d = mail.NewDialer(c.Host, c.Port, u, p) d = mail.NewDialer(c.Host, c.Port, u, p)
// use SSL // Use SSL
d.SSL = c.UseSSL d.SSL = c.UseSSL
// verify SSL cert chain // verify SSL cert chain
@ -83,6 +88,12 @@ func Connect(c Config) (d *mail.Dialer, err error) {
// TLS mode // TLS mode
d.StartTLSPolicy = mail.OpportunisticStartTLS d.StartTLSPolicy = mail.OpportunisticStartTLS
// Use FQDN of sending server if we have one.
c.SenderFQDN = strings.TrimSpace(c.SenderFQDN)
if len(c.SenderFQDN) > 0 {
d.LocalName = c.SenderFQDN
}
return d, nil return d, nil
} }

View file

@ -30,6 +30,11 @@
{{input id="smtp-senderName" type="text" value=model.smtp.senderName class=(if senderNameError "form-control is-invalid" "form-control")}} {{input id="smtp-senderName" type="text" value=model.smtp.senderName class=(if senderNameError "form-control is-invalid" "form-control")}}
<small class="form-text text-muted">e.g. Documize</small> <small class="form-text text-muted">e.g. Documize</small>
</div> </div>
<div class="form-group">
<label for="smtp-fqdn">Sender Server Fully Qualified Domain Name</label>
{{input id="smtp-fqdn" type="text" value=model.smtp.fqdn class="form-control"}}
<small class="form-text text-muted">(optional) SMTP can require valid domain name, e.g. docs.example.org</small>
</div>
<div class="form-group"> <div class="form-group">
<label>Anonymous Authentication (Ignore Credentials)</label> <label>Anonymous Authentication (Ignore Credentials)</label>
{{x-toggle value=model.smtp.anonymous size="medium" theme="light" onToggle=(action (mut model.smtp.anonymous))}} {{x-toggle value=model.smtp.anonymous size="medium" theme="light" onToggle=(action (mut model.smtp.anonymous))}}