Skip to content

Instantly share code, notes, and snippets.

@smtalim
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smtalim/2d4a079a365010f527c0 to your computer and use it in GitHub Desktop.
Save smtalim/2d4a079a365010f527c0 to your computer and use it in GitHub Desktop.
redditmail.go
package main
import (
"github.com/SatishTalim/redditnews"
"log"
"net/smtp"
)
func main() {
to := "satish@joshsoftware.com"
subject := "Go articles on Reddit"
message := redditnews.Email()
body := "To: " + to + "\r\nSubject: " +
subject + "\r\n\r\n" + message
auth := smtp.PlainAuth("", "satish.talim", "password", "smtp.gmail.com")
err := smtp.SendMail(
"smtp.gmail.com:587",
auth,
"satish.talim@gmail.com",
[]string{to},
[]byte(body))
if err != nil {
log.Fatal("SendMail: ", err)
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment