Install Gomail v2
masterTo install Gomail v2, use the following command to fetch the package via gopkg.in:
go get gopkg.in/gomail.v2repository·master·Indexed 26 days ago
https://github.com/go-gomail/gomailA Go package for sending emails via SMTP servers. Supports attachments, embedded images, HTML/text templates, and SSL/TLS.
To install Gomail v2, use the following command to fetch the package via gopkg.in:
go get gopkg.in/gomail.v2If you encounter the error x509: certificate signed by unknown authority, it means the SMTP server's certificate is not considered valid by the client. You can bypass certificate chain and hostname verification by setting the TLSConfig field on the dialer with InsecureSkipVerify: true.
Warning: This is insecure and should not be used in production environments.
package main
import (
"crypto/tls"
"gopkg.in/gomail.v2"
)
func main() {
d := gomail.NewDialer("smtp.example.com", 587, "user", "123456")
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
// Send emails using d.
}