How to send mail in GO language
package main
import (
"log"
"net/smtp"
)
func main() {
send("Nice to meet u my first golang gmail send successfull")
}
func send(body string) {
var passcode string
passcode = "123456"
from := "pt485368@gmail.com"
pass := "your password"
to := "pt485368@gmail.com"
mime := "MIME-version: 1.0;\nContent-Type: text/html;
charset=\"UTF-8\";\n\n"
charset=\"UTF-8\";\n\n"
msg := "From: " + from + "\n" +
"To: " + to + "\n" +
"Subject : RentMyHouse" + mime + "<html><body>
<form action ='hello.html'><input type='submit'
value =" + passcode + " name='Confirm_Otp'><input
type='hidden' value ='101 name='ID'></body></html>" +
<form action ='hello.html'><input type='submit'
value =" + passcode + " name='Confirm_Otp'><input
type='hidden' value ='101 name='ID'></body></html>" +
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.Print("sent, message sent successfully")
}