Skip to content

Instantly share code, notes, and snippets.

@RustyNails8
Created February 19, 2019 02:04
Show Gist options
  • Save RustyNails8/bdf8c7514ecfee4b9ee3bdcd580316c7 to your computer and use it in GitHub Desktop.
Save RustyNails8/bdf8c7514ecfee4b9ee3bdcd580316c7 to your computer and use it in GitHub Desktop.
Send Mail with Go
package main
import (
"log"
"net/smtp"
)
var (
from = "azure@microsoft.com"
msg = []byte("TEST VM STOP")
recipients = []string{"sumit.das@domain.com"}
)
func main() {
// hostname is used by PlainAuth to validate the TLS certificate.
hostname := "smtp.domain.com"
auth := smtp.PlainAuth("", "Domain\\user", "password", hostname)
err := smtp.SendMail(hostname+":25", auth, from, recipients, msg)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment