3 ms·
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
by ihsw 13y ago
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.
- staunch 13y agopackage main import ( "log" "net/smtp" "github.com/jordan-wright/email" ) func main() { e := email.NewEmail() e.From = "Jordan Wright <test@gmail.com>" e.To = []string{"test@example.com"} e.Bcc = []string{"test_bcc@example.com"} e.Cc = []string{"test_cc@example.com"} 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("", "x@gmail.com", "pw", "smtp.gmail.com")) if err != nil { log.Fatal(err) } }
- mratzloff 13y agoThere are dozens of instances of New() in the standard library.