Added syntax highlighting to README.md

Closes #1
This commit is contained in:
Yoshua Wuyts 2014-10-20 12:55:04 +02:00 committed by alexcesaro
parent 707e81ecee
commit ed0214dc63
1 changed files with 24 additions and 22 deletions

View File

@ -32,32 +32,34 @@ https://godoc.org/gopkg.in/gomail.v1
## Example ## Example
package main ```go
package main
import ( import (
"gopkg.in/gomail.v1" "gopkg.in/gomail.v1"
) )
func main() { func main() {
msg := gomail.NewMessage() msg := gomail.NewMessage()
msg.SetHeader("From", "alex@example.com") msg.SetHeader("From", "alex@example.com")
msg.SetHeader("To", "bob@example.com", "cora@example.com") msg.SetHeader("To", "bob@example.com", "cora@example.com")
msg.SetAddressHeader("Cc", "dan@example.com", "Dan") msg.SetAddressHeader("Cc", "dan@example.com", "Dan")
msg.SetHeader("Subject", "Hello!") msg.SetHeader("Subject", "Hello!")
msg.SetBody("text/html", "Hello <b>Bob</b> and <i>Cora</i>!") msg.SetBody("text/html", "Hello <b>Bob</b> and <i>Cora</i>!")
f, err := gomail.OpenFile("/home/Alex/lolcat.jpg") f, err := gomail.OpenFile("/home/Alex/lolcat.jpg")
if err != nil { if err != nil {
panic(err) panic(err)
} }
msg.Attach(f) msg.Attach(f)
// Send the email to Bob, Cora and Dan // Send the email to Bob, Cora and Dan
mailer := gomail.NewMailer("smtp.example.com", "user", "123456", 25) mailer := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
if err := mailer.Send(msg); err != nil { if err := mailer.Send(msg); err != nil {
panic(err) panic(err)
} }
} }
```
## Contact ## Contact