mirror of
https://github.com/1f349/tulip.git
synced 2024-11-14 15:51:40 +00:00
19 lines
540 B
Go
19 lines
540 B
Go
package mail
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"github.com/1f349/tulip/mail/templates"
|
|
"github.com/emersion/go-message/mail"
|
|
)
|
|
|
|
func (m *Mail) SendEmailTemplate(templateName, subject, nameOfUser string, to *mail.Address, data map[string]any) error {
|
|
var bufHtml, bufTxt bytes.Buffer
|
|
templates.RenderMailTemplate(&bufHtml, &bufTxt, templateName, map[string]any{
|
|
"ServiceName": m.Name,
|
|
"Name": nameOfUser,
|
|
"Data": data,
|
|
})
|
|
return m.SendMail(fmt.Sprintf("%s - %s", subject, m.Name), []*mail.Address{to}, &bufHtml, &bufTxt)
|
|
}
|