Skip to content

Instantly share code, notes, and snippets.

@yusufpapurcu
Created July 16, 2020 12:42
Show Gist options
  • Save yusufpapurcu/d846d48eb72be2397f0c32124f2fb19c to your computer and use it in GitHub Desktop.
Save yusufpapurcu/d846d48eb72be2397f0c32124f2fb19c to your computer and use it in GitHub Desktop.
package app
import (
"log"
"net/smtp"
)
func SendMail(to, sub, body string) {
from := "yusufturhanp@gmail.com"
pass := "cfavhrbebdhqtyvq"
msg := "From: " + from + "\n" +
"To: " + to + "\n" +
"Subject: " + sub + "\n" +
body
err := smtp.SendMail("smtp.gmail.com:587",
smtp.PlainAuth("", from, pass, "smtp.gmail.com"),
from, []string{to}, []byte(msg))
if err != nil {
log.Printf("smtp error: %s", err)
return
}
log.Println("Successfully sended to " + to)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment