Ejemplo n.º 1
0
func send_mail(content []byte) {
	m := gomail.NewMessage()
	m.SetHeader("From", "*****@*****.**")
	m.SetHeader("To", "*****@*****.**")
	m.SetHeader("Subject", "Hello!")
	m.SetBody("text/html",
		"<h1>Result</h1>"+
			"<p>"+string(content)+"</p>")
	d := gomail.NewDialer("smtp.mail.com", 465, "*****@*****.**", "****")
	if err := d.DialAndSend(m); err != nil {
		log.Error("Mail send faild!")
		panic(fmt.Sprintf("Mailing failed! (%s)", err))
	}
}
Ejemplo n.º 2
0
//NewSMTPEmailService creates a nes SMTPEmailService
func NewSMTPEmailService(host string, port int, user string, password string) (service *SMTPEmailService) {
	dialer := gomail.NewDialer(host, port, user, password)
	service = &SMTPEmailService{dialer: dialer}
	return
}