"Wrong host name" when using smtp on port 587
guillaumevillemont opened this issue · comments
Issue
I tried to setup rageshake on an OVH env with OVH smtp server that uses port 587.
When sending a report I just got an 500 Internal Server on the client api.
And on rageshake logs :
Oct 14 16:43:21 matrix-rageshake[10585]: 2022/10/14 14:43:21 Handling report submission; listing URI will be http://localhost:9110/api/listing/2022-10-14/144321-TUHJVFL8
Oct 14 16:43:21 matrix-rageshake[10585]: 2022/10/14 14:43:21 Error handling report submission: wrong host name
debug
Currently, we provide only smtp_server
variable where we put hostname:port
which is then used both during smtp.PlainAuth and smtp.Send.
It works when using port 25 but not port 587. I guess smtp.Send handle tls under the hood and that where the issue is.
Anyway, according to the doc and some tests, we should use hostname only on smtp.PlainAuth and hostname+port on smtp.Send
https://github.com/matrix-org/rageshake/blob/master/submit.go#L754
(currently) This does not work:
if s.cfg.SMTPPassword != "" || s.cfg.SMTPUsername != "" {
auth = smtp.PlainAuth("", s.cfg.SMTPUsername, s.cfg.SMTPPassword, "example.com:587")
}
err := e.Send("example.com:587", auth)
if err != nil {
return err
}
This should work :
if s.cfg.SMTPPassword != "" || s.cfg.SMTPUsername != "" {
auth = smtp.PlainAuth("", s.cfg.SMTPUsername, s.cfg.SMTPPassword, "example.com")
}
err := e.Send("example.com:587", auth)
if err != nil {
return err
}