Re:Show HN: email - Send emails easily in Go
by ihsw on Tuesday January 07, 2014 @02:30PM
(#7019296)
In actuality it would be `email.NewEmail()` -- the lack of namespace specificity is due to the code examples already being part of the package. The issue with a simple `New()` 'constructor' is that there is ambiguity as to what struct it's creating.
[ Parent
| on HN ]
Re:Show HN: email - Send emails easily in Go
by staunch on Tuesday January 07, 2014 @02:53PM
(#7019452)
package main
import (
"log"
"net/smtp"
"github.com/jordan-wright/email"
)
func main() {
e := email.NewEmail()
e.From = "Jordan Wright <[email protected]>"
e.To = []string{"[email protected]"}
e.Bcc = []string{"[email protected]"}
e.Cc = []string{"[email protected]"}
e.Subject = "Awesome Subject"
e.Text = "Text Body is, of course, supported!"
e.HTML = "<h1>Fancy HTML is supported, too!</h1>"
err := e.Send("smtp.gmail.com:587",
smtp.PlainAuth("", "[email protected]", "pw", "smtp.gmail.com"))
if err != nil {
log.Fatal(err)
}
}