From f6fd501841816f5e5c1c9a30fbc4c9a2a6f987bc Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 27 Nov 2022 10:08:40 +0000 Subject: Correct the fallbacks for mailer configuration (#21945) Unfortunately the fallback configuration code for [mailer] that were added in #18982 are incorrect. When you read a value from an ini section that key is added. This leads to a failure of the fallback mechanism. Further there is also a spelling mistake in the startTLS configuration. This PR restructures the mailer code to first map the deprecated settings on to the new ones - and then use ini.MapTo to map those on to the struct with additional validation as necessary. Ref #21744 Signed-off-by: Andrew Thornton --- services/mailer/mailer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'services/mailer') diff --git a/services/mailer/mailer.go b/services/mailer/mailer.go index 46b0c8e2f4..2663b6b2ba 100644 --- a/services/mailer/mailer.go +++ b/services/mailer/mailer.go @@ -166,7 +166,7 @@ func (s *smtpSender) Send(from string, to []string, msg io.WriterTo) error { defer conn.Close() var tlsconfig *tls.Config - if opts.Protocol == "smtps" || opts.Protocol == "smtp+startls" { + if opts.Protocol == "smtps" || opts.Protocol == "smtp+starttls" { tlsconfig = &tls.Config{ InsecureSkipVerify: opts.ForceTrustServerCert, ServerName: opts.SMTPAddr, @@ -208,7 +208,7 @@ func (s *smtpSender) Send(from string, to []string, msg io.WriterTo) error { } } - if opts.Protocol == "smtp+startls" { + if opts.Protocol == "smtp+starttls" { hasStartTLS, _ := client.Extension("STARTTLS") if hasStartTLS { if err = client.StartTLS(tlsconfig); err != nil { -- cgit v1.2.3