Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func sendmail(template *data.Template, attachments []*data.Attachment, recipient *data.Recipient, sender *data.Sender) error {
- m := gomail.NewMessage()
- m.SetHeader("From", m.FormatAddress(sender.Email, sender.GetFullName()))
- m.SetHeader("To", m.FormatAddress(recipient.Email, recipient.GetFullName()))
- m.SetHeader("Subject", template.Subject)
- for i := range attachments {
- m.Embed(mailer.WWW_Root+"/images/uploads/"+attachments[i].FileName, gomail.Rename(attachments[i].Name))
- }
- content, err := ParseTemplate(template, attachments, recipient, sender, true)
- if err != nil {
- return err
- }
- if template.Type == data.TYPE_HTML {
- m.SetBody("text/html", content)
- } else {
- m.SetBody("text/plain", content)
- }
- d := gomail.NewDialer(mailer.SMTP, mailer.Port, mailer.SMTPLogin, mailer.SMTPPassword)
- d.TLSConfig = &tls.Config{InsecureSkipVerify: mailer.SkipInsecureTLS}
- return d.DialAndSend(m)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement