fix(mail): add support for BCC in email sending
This commit is contained in:
@@ -27,6 +27,7 @@ email:
|
|||||||
smtp_pass: ""
|
smtp_pass: ""
|
||||||
from: ""
|
from: ""
|
||||||
to: "" # couple's inbox, receives RSVP + photo notifications
|
to: "" # couple's inbox, receives RSVP + photo notifications
|
||||||
|
bcc: "" # optional; comma-separated list of extra blind-copy recipients
|
||||||
|
|
||||||
upload:
|
upload:
|
||||||
max_size_mb: 15
|
max_size_mb: 15
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ type EmailConfig struct {
|
|||||||
SMTPPass string `yaml:"smtp_pass"`
|
SMTPPass string `yaml:"smtp_pass"`
|
||||||
From string `yaml:"from"`
|
From string `yaml:"from"`
|
||||||
To string `yaml:"to"`
|
To string `yaml:"to"`
|
||||||
|
Bcc string `yaml:"bcc"` // optional; comma-separated list of extra blind-copy recipients
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadConfig struct {
|
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,
|
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 {
|
func (m *Mailer) SendRSVP(r store.RSVP) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user