Example #1
0
func SendMail(to string, applier BasicUser, url string) error {
	msg := gomail.NewMessage()
	msg.SetHeader("From", "*****@*****.**")
	msg.SetHeader("To", to)
	msg.SetHeader("Subject", RecommLetterSubject)

	//Write letter template
	data := struct {
		ApplyUser BasicUser
		RecommUrl string
	}{
		ApplyUser: applier,
		RecommUrl: url,
	}
	buffer := new(bytes.Buffer)
	if e := RecommLetterTmpl.Execute(buffer, &data); e != nil {
		return e
	}
	msg.SetBody("text/plain", buffer.String())

	dialer := gomail.Dialer{
		Host: "localhost",
		Port: 25,
	}
	return dialer.DialAndSend(msg)
}
Example #2
0
//SendEvents implements Sender interface Send
func (sender *Sender) SendEvents(events notifier.EventsData, contact notifier.ContactData, trigger notifier.TriggerData, throttled bool) error {

	m := sender.MakeMessage(events, contact, trigger, throttled)

	d := gomail.Dialer{Host: sender.SMTPhost, Port: sender.SMTPport, TLSConfig: &tls.Config{InsecureSkipVerify: sender.InsecureTLS}}
	if err := d.DialAndSend(m); err != nil {
		return err
	}
	return nil
}