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 }