Posts Tagged tls

Sending mail using TLS with Go

As I did not find any example of go program which is sending UTF-8 mail with TLS, I decided to create my own go package with this functionality + example, find more details here: https://github.com/bykovme/tlsmailgo-mascot-mail

 

Mail message can be sent this easy:

 

mail := tlsmail.TLSMail{
	Host:     "mail.your_favorite_hosting_provider.here",  
	Port:     "465",                           
	Sender:   "noreply@mail_from.here",        
	Password: "123456",                        
	TO:       []string{"mail1@mail_to.here"},
	Subject:  subject,                       
	Body:     body,                          
}

err := mail.Send()

if err != nil {
	log.Println("Mail send failure: " + err.Error())
} else {
	log.Println("Mail sent successfully")
}

Enjoy!

, , , , ,

Leave a comment