Send a new email
(ctx context.Context, email *Email)
| 39 | |
| 40 | // Send a new email |
| 41 | func (mailer *smtpMailer) Send(ctx context.Context, email *Email) (err error) { |
| 42 | ctx, span := mailer.tracer.Start(ctx) |
| 43 | defer span.End() |
| 44 | |
| 45 | e := mail.NewEmail() |
| 46 | e.From = mailer.from |
| 47 | e.To = []string{email.toAddress()} |
| 48 | e.Subject = email.Subject |
| 49 | e.Text = []byte(email.Text) |
| 50 | e.HTML = []byte(email.HTML) |
| 51 | |
| 52 | err = e.Send(mailer.address, mailer.auth) |
| 53 | if err != nil { |
| 54 | return stacktrace.Propagate(err, "cannot send email") |
| 55 | } |
| 56 | |
| 57 | return nil |
| 58 | } |