From 8b52e6e72e17f0d1df0eeaa7a8e9d8e1ccbaece7 Mon Sep 17 00:00:00 2001 From: Michael Albert Date: Mon, 6 Dec 2021 19:32:34 +0100 Subject: [PATCH 1/4] Fix email support --- main.go | 2 ++ rageshake.sample.yaml | 3 ++- submit.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index b678512..b0a919f 100644 --- a/main.go +++ b/main.go @@ -67,6 +67,8 @@ type config struct { SMTPServer string `yaml:"smtp_server"` + SMTPServerPort string `yaml:"smtp_port"` + SMTPUsername string `yaml:"smtp_username"` SMTPPassword string `yaml:"smtp_password"` diff --git a/rageshake.sample.yaml b/rageshake.sample.yaml index efcdb01..c8e226f 100644 --- a/rageshake.sample.yaml +++ b/rageshake.sample.yaml @@ -47,6 +47,7 @@ email_addresses: email_from: Rageshake # SMTP server configuration -smtp_server: localhost:25 +smtp_server: localhost +smtp_port: 25 smtp_username: myemailuser smtp_password: myemailpass diff --git a/submit.go b/submit.go index 799dea9..7ec0afa 100644 --- a/submit.go +++ b/submit.go @@ -666,7 +666,7 @@ func (s *submitServer) sendEmail(p parsedPayload, reportDir string) error { if s.cfg.SMTPPassword != "" || s.cfg.SMTPUsername != "" { auth = smtp.PlainAuth("", s.cfg.SMTPUsername, s.cfg.SMTPPassword, s.cfg.SMTPServer) } - err := e.Send(s.cfg.SMTPServer, auth) + err := e.Send(s.cfg.SMTPServer+":"+s.cfg.SMTPServerPort, auth) if err != nil { return err } From 82d172ac15898b94620eaaa27bde78af2a5b0a30 Mon Sep 17 00:00:00 2001 From: Michael Albert <37796947+awesome-michael@users.noreply.github.com> Date: Mon, 6 Dec 2021 19:49:15 +0100 Subject: [PATCH 2/4] Create 38.misc --- changelog.d/38.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/38.misc diff --git a/changelog.d/38.misc b/changelog.d/38.misc new file mode 100644 index 0000000..4173609 --- /dev/null +++ b/changelog.d/38.misc @@ -0,0 +1 @@ +Fix email support. From 710dca0fd80fad04ca31d0395be5266124976e4e Mon Sep 17 00:00:00 2001 From: Michael Albert Date: Fri, 17 Dec 2021 20:22:43 +0100 Subject: [PATCH 3/4] Use net/SplitHostPort --- changelog.d/38.bugfix | 1 + changelog.d/38.misc | 1 - main.go | 2 -- rageshake.sample.yaml | 3 +-- submit.go | 6 ++++-- 5 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 changelog.d/38.bugfix delete mode 100644 changelog.d/38.misc diff --git a/changelog.d/38.bugfix b/changelog.d/38.bugfix new file mode 100644 index 0000000..3f83830 --- /dev/null +++ b/changelog.d/38.bugfix @@ -0,0 +1 @@ +Fix email support to support mail setups with different ports than 25. diff --git a/changelog.d/38.misc b/changelog.d/38.misc deleted file mode 100644 index 4173609..0000000 --- a/changelog.d/38.misc +++ /dev/null @@ -1 +0,0 @@ -Fix email support. diff --git a/main.go b/main.go index b0a919f..b678512 100644 --- a/main.go +++ b/main.go @@ -67,8 +67,6 @@ type config struct { SMTPServer string `yaml:"smtp_server"` - SMTPServerPort string `yaml:"smtp_port"` - SMTPUsername string `yaml:"smtp_username"` SMTPPassword string `yaml:"smtp_password"` diff --git a/rageshake.sample.yaml b/rageshake.sample.yaml index c8e226f..efcdb01 100644 --- a/rageshake.sample.yaml +++ b/rageshake.sample.yaml @@ -47,7 +47,6 @@ email_addresses: email_from: Rageshake # SMTP server configuration -smtp_server: localhost -smtp_port: 25 +smtp_server: localhost:25 smtp_username: myemailuser smtp_password: myemailpass diff --git a/submit.go b/submit.go index 7ec0afa..3b0b093 100644 --- a/submit.go +++ b/submit.go @@ -27,6 +27,7 @@ import ( "log" "mime" "mime/multipart" + "net" "net/http" "net/smtp" "os" @@ -664,9 +665,10 @@ func (s *submitServer) sendEmail(p parsedPayload, reportDir string) error { var auth smtp.Auth = nil if s.cfg.SMTPPassword != "" || s.cfg.SMTPUsername != "" { - auth = smtp.PlainAuth("", s.cfg.SMTPUsername, s.cfg.SMTPPassword, s.cfg.SMTPServer) + host, _, _ := net.SplitHostPort(s.cfg.SMTPServer) + auth = smtp.PlainAuth("", s.cfg.SMTPUsername, s.cfg.SMTPPassword, host) } - err := e.Send(s.cfg.SMTPServer+":"+s.cfg.SMTPServerPort, auth) + err := e.Send(s.cfg.SMTPServer, auth) if err != nil { return err } From bcf30aee5b22ed1da5c82f1bd28f726e865961e2 Mon Sep 17 00:00:00 2001 From: Michael Albert Date: Mon, 4 Apr 2022 15:23:27 +0200 Subject: [PATCH 4/4] Reword changelog Signed-off-by: Michael Albert --- changelog.d/38.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/38.bugfix b/changelog.d/38.bugfix index 3f83830..08dc145 100644 --- a/changelog.d/38.bugfix +++ b/changelog.d/38.bugfix @@ -1 +1 @@ -Fix email support to support mail setups with different ports than 25. +Fix email support to support authenticated mail with a custom port.