mirror of
https://github.com/documize/community.git
synced 2025-07-18 20:59:43 +02:00
Allow SMTP config to specify FQDN of sending server
/cc @backba
This commit is contained in:
parent
560f786b8b
commit
2510972a83
3 changed files with 20 additions and 2 deletions
|
@ -56,5 +56,7 @@ func GetSMTPConfig(s *store.Store) (c smtp.Config) {
|
|||
c.SkipSSLVerify, _ = strconv.ParseBool(verifySSL)
|
||||
c.SkipSSLVerify = true
|
||||
|
||||
c.SenderFQDN, _ = s.Setting.Get("SMTP", "fqdn")
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -51,6 +51,11 @@ type Config struct {
|
|||
|
||||
// SkipSSLVerify allows unverified certificates
|
||||
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
|
||||
|
@ -71,10 +76,10 @@ func Connect(c Config) (d *mail.Dialer, err error) {
|
|||
p = base64.StdEncoding.EncodeToString([]byte(p))
|
||||
}
|
||||
|
||||
// basic server
|
||||
// Basic server
|
||||
d = mail.NewDialer(c.Host, c.Port, u, p)
|
||||
|
||||
// use SSL
|
||||
// Use SSL
|
||||
d.SSL = c.UseSSL
|
||||
|
||||
// verify SSL cert chain
|
||||
|
@ -83,6 +88,12 @@ func Connect(c Config) (d *mail.Dialer, err error) {
|
|||
// TLS mode
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@
|
|||
{{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>
|
||||
</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">
|
||||
<label>Anonymous Authentication (Ignore Credentials)</label>
|
||||
{{x-toggle value=model.smtp.anonymous size="medium" theme="light" onToggle=(action (mut model.smtp.anonymous))}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue