Add To: header when constructing emails (#28507)

#28032
This commit is contained in:
Dante Catalfamo 2025-04-24 09:00:35 -04:00 committed by GitHub
parent 862739292e
commit 4934aee8fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1 @@
- Fixed missing To: email header

View file

@ -78,7 +78,13 @@ func getMessageBody(e fleet.Email, f fromFunc) ([]byte, error) {
if err != nil {
return nil, fmt.Errorf("failed to obtain from address: %w", err)
}
msg := []byte(subject + from + mime + content + "\r\n" + string(body) + "\r\n")
to := ""
if len(e.To) == 1 {
to = "To: " + e.To[0] + "\r\n"
} else if len(e.To) > 1 {
to = "To: undisclosed-recipients\r\n"
}
msg := []byte(subject + from + to + mime + content + "\r\n" + string(body) + "\r\n")
return msg, nil
}