Skip to content

Commit

Permalink
prepending text/plain if present
Browse files Browse the repository at this point in the history
  • Loading branch information
paganotoni committed Aug 3, 2021
1 parent 71013c6 commit c32bafb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sendgrid_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,17 @@ func buildMail(m mail.Message) (*smail.SGMailV3, error) {
}

mm.AddPersonalizations(p)
contents := []*smail.Content{}
for _, b := range m.Bodies {
mm.AddContent(smail.NewContent(b.ContentType, m.Bodies[0].Content))
if b.ContentType == "text/plain" {
contents = append([]*smail.Content{smail.NewContent(b.ContentType, b.Content)}, contents...)
continue
}
contents = append(contents, smail.NewContent(b.ContentType, m.Bodies[0].Content))
}

mm.AddContent(contents...)

for _, a := range m.Attachments {
b := new(bytes.Buffer)
if n, err := b.ReadFrom(a.Reader); err != nil {
Expand Down

0 comments on commit c32bafb

Please sign in to comment.