Fixed commented examples

This commit is contained in:
Alexandre Cesaro 2015-07-16 19:35:21 +02:00
parent 3346e955b2
commit 867c4d1580
2 changed files with 6 additions and 13 deletions

View File

@ -47,16 +47,12 @@ func main() {
msg.SetAddressHeader("Cc", "dan@example.com", "Dan")
msg.SetHeader("Subject", "Hello!")
msg.SetBody("text/html", "Hello <b>Bob</b> and <i>Cora</i>!")
msg.Attach(gomail.NewFile("/home/Alex/lolcat.jpg"))
f, err := gomail.OpenFile("/home/Alex/lolcat.jpg")
if err != nil {
panic(err)
}
msg.Attach(f)
d := gomail.NewPlainDialer("smtp.example.com", "user", "123456", 587)
// Send the email to Bob, Cora and Dan
mailer := gomail.NewMailer("smtp.example.com", "user", "123456", 587)
if err := mailer.Send(msg); err != nil {
if err := d.DialAndSend(msg); err != nil {
panic(err)
}
}
@ -72,7 +68,8 @@ considered valid by the client running Gomail. As a quick workaround you can
bypass the verification of the server's certificate chain and host name by using
`SetTLSConfig`:
mailer := gomail.NewMailer("smtp.example.com", "user", "123456", 587, gomail.SetTLSConfig(&tls.Config{InsecureSkipVerify: true}))
d := gomail.NewPlainDialer("smtp.example.com", "user", "123456", 587)
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
Note, however, that this is insecure and should not be used in production.

View File

@ -299,11 +299,7 @@ func (m *Message) Attach(f ...*File) {
//
// Example:
//
// f, err := gomail.OpenFile("/tmp/image.jpg")
// if err != nil {
// panic(err)
// }
// m.Embed(f)
// m.Embed(gomail.NewFile("/tmp/image.jpg"))
// m.SetBody("text/html", `<img src="cid:image.jpg" alt="My image" />`)
func (m *Message) Embed(image ...*File) {
if m.embedded == nil {