fix(mail): add support for BCC in email sending
This commit is contained in:
@@ -27,6 +27,7 @@ email:
|
||||
smtp_pass: ""
|
||||
from: ""
|
||||
to: "" # couple's inbox, receives RSVP + photo notifications
|
||||
bcc: "" # optional; comma-separated list of extra blind-copy recipients
|
||||
|
||||
upload:
|
||||
max_size_mb: 15
|
||||
|
||||
@@ -53,6 +53,7 @@ type EmailConfig struct {
|
||||
SMTPPass string `yaml:"smtp_pass"`
|
||||
From string `yaml:"from"`
|
||||
To string `yaml:"to"`
|
||||
Bcc string `yaml:"bcc"` // optional; comma-separated list of extra blind-copy recipients
|
||||
}
|
||||
|
||||
type UploadConfig struct {
|
||||
|
||||
@@ -48,7 +48,14 @@ func (m *Mailer) send(subject, body string) error {
|
||||
m.cfg.From, m.cfg.To, subject, newMessageID(m.cfg.From), time.Now().Format(time.RFC1123Z), body,
|
||||
)
|
||||
|
||||
return smtp.SendMail(addr, auth, m.cfg.From, []string{m.cfg.To}, []byte(msg))
|
||||
recipients := []string{m.cfg.To}
|
||||
for _, bcc := range strings.Split(m.cfg.Bcc, ",") {
|
||||
if bcc = strings.TrimSpace(bcc); bcc != "" {
|
||||
recipients = append(recipients, bcc)
|
||||
}
|
||||
}
|
||||
|
||||
return smtp.SendMail(addr, auth, m.cfg.From, recipients, []byte(msg))
|
||||
}
|
||||
|
||||
func (m *Mailer) SendRSVP(r store.RSVP) error {
|
||||
|
||||
Reference in New Issue
Block a user