view pkg/misc/mail.go @ 656:9ef2f80a4645

Fix syntax error in schema script serial is a data type, just like int, and only one can be given. In passing use the standard conforming way to specify the auto-generated column and make it the real primary key.
author Tom Gottfried <tom@intevation.de>
date Fri, 14 Sep 2018 16:57:12 +0200
parents c1047fd04a3a
children a244b18cb916
line wrap: on
line source

package misc

import (
	gomail "gopkg.in/gomail.v2"

	"gemma.intevation.de/gemma/pkg/config"
)

func SendMail(email, subject, body string) error {
	m := gomail.NewMessage()
	m.SetHeader("From", config.MailFrom())
	m.SetHeader("To", email)
	m.SetHeader("Subject", subject)
	m.SetBody("text/plain", body)

	d := gomail.Dialer{
		Host:      config.MailHost(),
		Port:      int(config.MailPort()),
		Username:  config.MailUser(),
		Password:  config.MailPassword(),
		LocalName: config.MailHelo(),
		SSL:       config.MailPort() == 465,
	}

	return d.DialAndSend(m)
}