Skip to content

Commit

Permalink
Use net/SplitHostPort
Browse files Browse the repository at this point in the history
  • Loading branch information
awesome-michael committed Dec 17, 2021
1 parent 82d172a commit 710dca0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.d/38.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix email support to support mail setups with different ports than 25.
1 change: 0 additions & 1 deletion changelog.d/38.misc

This file was deleted.

2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 1 addition & 2 deletions rageshake.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ email_addresses:
email_from: Rageshake <[email protected]>

# SMTP server configuration
smtp_server: localhost
smtp_port: 25
smtp_server: localhost:25
smtp_username: myemailuser
smtp_password: myemailpass
6 changes: 4 additions & 2 deletions submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"log"
"mime"
"mime/multipart"
"net"
"net/http"
"net/smtp"
"os"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 710dca0

Please sign in to comment.