[BUGFIX] Add ability to specify SMTP HELO/EHLO identifier (#1416)
* add docs * add configuration option for SMTP called `identifier` * default should act the same as beforepull/1425/head
parent
898cfbd206
commit
956dbfb8de
|
@ -400,6 +400,8 @@ notifier:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 1025
|
port: 1025
|
||||||
sender: admin@example.com
|
sender: admin@example.com
|
||||||
|
# HELO/EHLO Identifier. Some SMTP Servers may reject the default of localhost.
|
||||||
|
identifier: localhost
|
||||||
# Subject configuration of the emails sent.
|
# Subject configuration of the emails sent.
|
||||||
# {title} is replaced by the text from the notifier
|
# {title} is replaced by the text from the notifier
|
||||||
subject: "[Authelia] {title}"
|
subject: "[Authelia] {title}"
|
||||||
|
|
|
@ -43,6 +43,8 @@ notifier:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 1025
|
port: 1025
|
||||||
sender: admin@example.com
|
sender: admin@example.com
|
||||||
|
# HELO/EHLO Identifier. Some SMTP Servers may reject the default of localhost.
|
||||||
|
identifier: localhost
|
||||||
# Subject configuration of the emails sent.
|
# Subject configuration of the emails sent.
|
||||||
# {title} is replaced by the text from the notifier
|
# {title} is replaced by the text from the notifier
|
||||||
subject: "[Authelia] {title}"
|
subject: "[Authelia] {title}"
|
||||||
|
@ -59,6 +61,10 @@ notifier:
|
||||||
Most configuration options are self-explanatory, however here is an explanation of the ones that may not
|
Most configuration options are self-explanatory, however here is an explanation of the ones that may not
|
||||||
be as obvious.
|
be as obvious.
|
||||||
|
|
||||||
|
### identifier
|
||||||
|
The name to send to the SMTP server as the identifier with the HELO/EHLO command. Some SMTP providers like Google Mail
|
||||||
|
reject the message if it's localhost.
|
||||||
|
|
||||||
### subject
|
### subject
|
||||||
This is the subject Authelia will use in the email, it has a single placeholder at present `{title}` which should
|
This is the subject Authelia will use in the email, it has a single placeholder at present `{title}` which should
|
||||||
be included in all emails as it is the internal descriptor for the contents of the email.
|
be included in all emails as it is the internal descriptor for the contents of the email.
|
||||||
|
|
|
@ -11,6 +11,7 @@ type SMTPNotifierConfiguration struct {
|
||||||
Port int `mapstructure:"port"`
|
Port int `mapstructure:"port"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `mapstructure:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `mapstructure:"password"`
|
||||||
|
Identifier string `mapstructure:"identifier"`
|
||||||
Sender string `mapstructure:"sender"`
|
Sender string `mapstructure:"sender"`
|
||||||
Subject string `mapstructure:"subject"`
|
Subject string `mapstructure:"subject"`
|
||||||
TrustedCert string `mapstructure:"trusted_cert"`
|
TrustedCert string `mapstructure:"trusted_cert"`
|
||||||
|
@ -29,5 +30,6 @@ type NotifierConfiguration struct {
|
||||||
|
|
||||||
// DefaultSMTPNotifierConfiguration represents default configuration parameters for the SMTP notifier.
|
// DefaultSMTPNotifierConfiguration represents default configuration parameters for the SMTP notifier.
|
||||||
var DefaultSMTPNotifierConfiguration = SMTPNotifierConfiguration{
|
var DefaultSMTPNotifierConfiguration = SMTPNotifierConfiguration{
|
||||||
Subject: "[Authelia] {title}",
|
Subject: "[Authelia] {title}",
|
||||||
|
Identifier: "localhost",
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ var validKeys = []string{
|
||||||
"notifier.smtp.password",
|
"notifier.smtp.password",
|
||||||
"notifier.smtp.host",
|
"notifier.smtp.host",
|
||||||
"notifier.smtp.port",
|
"notifier.smtp.port",
|
||||||
|
"notifier.smtp.identifier",
|
||||||
"notifier.smtp.sender",
|
"notifier.smtp.sender",
|
||||||
"notifier.smtp.subject",
|
"notifier.smtp.subject",
|
||||||
"notifier.smtp.startup_check_address",
|
"notifier.smtp.startup_check_address",
|
||||||
|
|
|
@ -47,6 +47,10 @@ func ValidateNotifier(configuration *schema.NotifierConfiguration, validator *sc
|
||||||
configuration.SMTP.Subject = schema.DefaultSMTPNotifierConfiguration.Subject
|
configuration.SMTP.Subject = schema.DefaultSMTPNotifierConfiguration.Subject
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if configuration.SMTP.Identifier == "" {
|
||||||
|
configuration.SMTP.Identifier = schema.DefaultSMTPNotifierConfiguration.Identifier
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ type SMTPNotifier struct {
|
||||||
username string
|
username string
|
||||||
password string
|
password string
|
||||||
sender string
|
sender string
|
||||||
|
identifier string
|
||||||
host string
|
host string
|
||||||
port int
|
port int
|
||||||
trustedCert string
|
trustedCert string
|
||||||
|
@ -39,6 +40,7 @@ func NewSMTPNotifier(configuration schema.SMTPNotifierConfiguration) *SMTPNotifi
|
||||||
username: configuration.Username,
|
username: configuration.Username,
|
||||||
password: configuration.Password,
|
password: configuration.Password,
|
||||||
sender: configuration.Sender,
|
sender: configuration.Sender,
|
||||||
|
identifier: configuration.Identifier,
|
||||||
host: configuration.Host,
|
host: configuration.Host,
|
||||||
port: configuration.Port,
|
port: configuration.Port,
|
||||||
trustedCert: configuration.TrustedCert,
|
trustedCert: configuration.TrustedCert,
|
||||||
|
@ -277,6 +279,10 @@ func (n *SMTPNotifier) StartupCheck() (bool, error) {
|
||||||
|
|
||||||
defer n.cleanup()
|
defer n.cleanup()
|
||||||
|
|
||||||
|
if err := n.client.Hello(n.identifier); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
if err := n.startTLS(); err != nil {
|
if err := n.startTLS(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -311,6 +317,10 @@ func (n *SMTPNotifier) Send(recipient, title, body, htmlBody string) error {
|
||||||
// Always execute QUIT at the end once we're connected.
|
// Always execute QUIT at the end once we're connected.
|
||||||
defer n.cleanup()
|
defer n.cleanup()
|
||||||
|
|
||||||
|
if err := n.client.Hello(n.identifier); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Start TLS and then Authenticate.
|
// Start TLS and then Authenticate.
|
||||||
if err := n.startTLS(); err != nil {
|
if err := n.startTLS(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue