Mercurial > gemma
view misc/mail.go @ 412:21fb992b1f5a
merge
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 15 Aug 2018 16:54:49 +0200 |
parents | 33b59c848771 |
children |
line wrap: on
line source
package misc import ( gomail "gopkg.in/gomail.v2" "gemma.intevation.de/gemma/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) }