smtp/util.go
func SendMailSSL(addr string, a smtp.Auth, from string, to []string, msg []byte) error {
	conn, err := tls.Dial("tcp", addr, &tls.Config{InsecureSkipVerify: true}) //TODO: Not secure
	if err != nil {
		log.Println("Error Dialing", err)
		return err
	}
	h, _, _ := net.SplitHostPort(addr)
	c, err := smtp.NewClient(conn, h)
	if err != nil {
		log.Println("Error SMTP connection", err)
		return err
	}
	defer c.Close()

	if a != nil {
		if ok, _ := c.Extension("AUTH"); ok {
			if err = c.Auth(a); err != nil {
				log.Printf("Authentication error: %v", err)
				return err
			}
		}
	}

	if err = c.Mail(from); err != nil {
		log.Printf("From error: %v", err)
		return err
	}

	for _, addr := range to {
		if err = c.Rcpt(addr); err != nil {
			log.Printf("Recipient error: %v", err)
			return err
		}
	}

	w, err := c.Data()
	if err != nil {
		return err
	}

	w.Write(msg)
	w.Close()

	return c.Quit()
}
func SendMailSSL(addr string, a smtp.Auth, from string, to []string, msg []byte) error {
	conn, err := tls.Dial("tcp", addr, &tls.Config{InsecureSkipVerify: true}) //TODO: Not secure
	if err != nil {
		log.Println("Error Dialing", err)
		return err
	}
	h, _, _ := net.SplitHostPort(addr)
	c, err := smtp.NewClient(conn, h)
	if err != nil {
		log.Println("Error SMTP connection", err)
		return err
	}
	defer c.Close()

	if a != nil {
		if ok, _ := c.Extension("AUTH"); ok {
			if err = c.Auth(a); err != nil {
				log.Printf("Authentication error: %v", err)
				return err
			}
		}
	}

	if err = c.Mail(from); err != nil {
		log.Printf("From error: %v", err)
		return err
	}

	for _, addr := range to {
		if err = c.Rcpt(addr); err != nil {
			log.Printf("Recipient error: %v", err)
			return err
		}
	}

	w, err := c.Data()
	if err != nil {
		return err
	}

	w.Write(msg)
	w.Close()

	return c.Quit()
}
// SendMailSSL envoie un email par SSL