From b2ed234d7473676d66436ed23c3ec44b26ec3f1c Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Mon, 6 Jul 2026 16:02:14 +0300 Subject: [PATCH] added Cc and Bcc headers to the sendmail command --- CHANGELOG.md | 4 +++- tools/mailer/sendmail.go | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89a20b3b..257b2d91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## v0.39.6 (WIP) -- (@todo prepare announcement explaining the options) Added extra hardening options to the Microsoft OAuth2 provider allowing devs to specify the preferred safe email extraction method. +- Added `Cc` and `Bcc` recipients to the dev `sendmail` command for consistency with the SMTP mailer. + +- (@todo prepare announcement explaining the options) Added extra hardening options to the Microsoft OAuth2 provider allowing developers to specify the preferred safe email extraction method. - (@todo) Bumped the min Go GitHub action version to 1.26.5 as it includes some [minor security fixes](https://github.com/golang/go/issues?q=milestone%3AGo1.26.5). diff --git a/tools/mailer/sendmail.go b/tools/mailer/sendmail.go index b1dbaec4..035233ab 100644 --- a/tools/mailer/sendmail.go +++ b/tools/mailer/sendmail.go @@ -49,6 +49,14 @@ func (c *Sendmail) send(m *Message) error { headers.Set("Content-Type", "text/html; charset=UTF-8") headers.Set("To", strings.Join(toAddresses, ",")) + if len(m.Cc) > 0 { + headers.Set("Cc", strings.Join(addressesToStrings(m.Cc, false), ",")) + } + + if len(m.Bcc) > 0 { + headers.Set("Bcc", strings.Join(addressesToStrings(m.Bcc, false), ",")) + } + cmdPath, err := findSendmailPath() if err != nil { return err @@ -75,7 +83,7 @@ func (c *Sendmail) send(m *Message) error { } // --- - sendmail := exec.Command(cmdPath, strings.Join(toAddresses, ",")) + sendmail := exec.Command(cmdPath, "-i", "-t") sendmail.Stdin = &buffer return sendmail.Run()