Created
February 19, 2019 02:04
-
-
Save RustyNails8/bdf8c7514ecfee4b9ee3bdcd580316c7 to your computer and use it in GitHub Desktop.
Send Mail with Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/smtp" | |
) | |
var ( | |
from = "[email protected]" | |
msg = []byte("TEST VM STOP") | |
recipients = []string{"[email protected]"} | |
) | |
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