Set 'To' addresses on Letter email after message is prepared
This works with mailgun.AddRecipientAndVariables, so we can safely send emails to a large number of recipients beyond Mailgun's 1,000-recipient limit. Ref T856
This commit is contained in:
parent
2288ccf2a2
commit
e963755393
1 changed files with 15 additions and 13 deletions
28
email.go
28
email.go
|
@ -328,19 +328,6 @@ Sent to %recipient.to%. Unsubscribe: ` + p.Collection.CanonicalURL() + `email/un
|
||||||
if len(subs) == 0 {
|
if len(subs) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Info("[email] Adding %d recipient(s)", len(subs))
|
|
||||||
for _, s := range subs {
|
|
||||||
e := s.FinalEmail(app.keys)
|
|
||||||
log.Info("[email] Adding %s", e)
|
|
||||||
err = m.AddRecipientAndVariables(e, map[string]interface{}{
|
|
||||||
"id": s.ID,
|
|
||||||
"to": e,
|
|
||||||
"token": s.Token,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Unable to add receipient %s: %s", e, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if title != "" {
|
if title != "" {
|
||||||
title = string(`<h2 id="title">` + p.FormattedDisplayTitle() + `</h2>`)
|
title = string(`<h2 id="title">` + p.FormattedDisplayTitle() + `</h2>`)
|
||||||
|
@ -425,6 +412,21 @@ Sent to %recipient.to%. Unsubscribe: ` + p.Collection.CanonicalURL() + `email/un
|
||||||
}
|
}
|
||||||
|
|
||||||
m.SetHtml(html)
|
m.SetHtml(html)
|
||||||
|
|
||||||
|
log.Info("[email] Adding %d recipient(s)", len(subs))
|
||||||
|
for _, s := range subs {
|
||||||
|
e := s.FinalEmail(app.keys)
|
||||||
|
log.Info("[email] Adding %s", e)
|
||||||
|
err = m.AddRecipientAndVariables(e, map[string]interface{}{
|
||||||
|
"id": s.ID,
|
||||||
|
"to": e,
|
||||||
|
"token": s.Token,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Unable to add receipient %s: %s", e, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
res, _, err := gun.Send(m)
|
res, _, err := gun.Send(m)
|
||||||
log.Info("[email] Send result: %s", res)
|
log.Info("[email] Send result: %s", res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue