mailme
package main
import (
"flag"
"net/smtp"
"github.com/Sirupsen/logrus"
)
var (
to = flag.String("to", "***********@gmail.com", "To")
subject = flag.String("s", "?", "Subject")
message = flag.String("m", "Hello there!", "Message")
)
func main() {
flag.Parse()
send(*message)
}
func send(body string) {
from := "*@gmail.com"
pass := "******************"
auth := smtp.PlainAuth(*subject, from, pass, "smtp.gmail.com")
msg := []byte("To: " + *to + "\r\n" +
"Subject: " + *subject + "\r\n" +
"\r\n" +
*message + "\r\n")
err := smtp.SendMail("smtp.gmail.com:587",
auth, from, []string{*to}, []byte(msg))
if err != nil {
logrus.Printf("smtp error: %s", err)
return
}
logrus.Print("Mail sent!")
}