Created
July 16, 2020 12:42
-
-
Save yusufpapurcu/d846d48eb72be2397f0c32124f2fb19c to your computer and use it in GitHub Desktop.
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 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