在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:jordan-wright/email开源软件地址:https://github.com/jordan-wright/email开源编程语言:Go 100.0%开源软件介绍:Robust and flexible email library for Go Email for humansThe The
Installation
Note: Version > 1 of this library requires Go v1.5 or above. If you need compatibility with previous Go versions, you can use the previous package at gopkg.in/jordan-wright/email.v1 ExamplesSending email using Gmaile := 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 = []byte("Text Body is, of course, supported!")
e.HTML = []byte("<h1>Fancy HTML is supported, too!</h1>")
e.Send("smtp.gmail.com:587", smtp.PlainAuth("", "[email protected]", "password123", "smtp.gmail.com")) Another Method for Creating an EmailYou can also create an email directly by creating a struct as follows: e := &email.Email {
To: []string{"[email protected]"},
From: "Jordan Wright <[email protected]>",
Subject: "Awesome Subject",
Text: []byte("Text Body is, of course, supported!"),
HTML: []byte("<h1>Fancy HTML is supported, too!</h1>"),
Headers: textproto.MIMEHeader{},
} Creating an Email From an io.ReaderYou can also create an email from any type that implements the Attaching a Filee := NewEmail()
e.AttachFile("test.txt") A Pool of Reusable Connections(var ch <-chan *email.Email)
p := email.NewPool(
"smtp.gmail.com:587",
4,
smtp.PlainAuth("", "[email protected]", "password123", "smtp.gmail.com"),
)
for i := 0; i < 4; i++ {
go func() {
for e := range ch {
p.Send(e, 10 * time.Second)
}
}()
} Documentationhttp://godoc.org/github.com/jordan-wright/email Other SourcesSections inspired by the handy gophermail project. ContributorsI'd like to thank all the contributors and maintainers of this package. A special thanks goes out to Jed Denlea jeddenlea for his numerous contributions and optimizations. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论