From ed0214dc637f5c8f907879c58077b0d36cd5843f Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Mon, 20 Oct 2014 12:55:04 +0200 Subject: [PATCH] Added syntax highlighting to README.md Closes #1 --- README.md | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 1d26eec..fb3e56c 100644 --- a/README.md +++ b/README.md @@ -32,32 +32,34 @@ https://godoc.org/gopkg.in/gomail.v1 ## Example - package main +```go +package main - import ( - "gopkg.in/gomail.v1" - ) +import ( + "gopkg.in/gomail.v1" +) - func main() { - msg := gomail.NewMessage() - msg.SetHeader("From", "alex@example.com") - msg.SetHeader("To", "bob@example.com", "cora@example.com") - msg.SetAddressHeader("Cc", "dan@example.com", "Dan") - msg.SetHeader("Subject", "Hello!") - msg.SetBody("text/html", "Hello Bob and Cora!") +func main() { + msg := gomail.NewMessage() + msg.SetHeader("From", "alex@example.com") + msg.SetHeader("To", "bob@example.com", "cora@example.com") + msg.SetAddressHeader("Cc", "dan@example.com", "Dan") + msg.SetHeader("Subject", "Hello!") + msg.SetBody("text/html", "Hello Bob and Cora!") - f, err := gomail.OpenFile("/home/Alex/lolcat.jpg") - if err != nil { - panic(err) - } - msg.Attach(f) + f, err := gomail.OpenFile("/home/Alex/lolcat.jpg") + if err != nil { + panic(err) + } + msg.Attach(f) - // Send the email to Bob, Cora and Dan - mailer := gomail.NewMailer("smtp.example.com", "user", "123456", 25) - if err := mailer.Send(msg); err != nil { - panic(err) - } - } + // Send the email to Bob, Cora and Dan + mailer := gomail.NewMailer("smtp.example.com", "user", "123456", 25) + if err := mailer.Send(msg); err != nil { + panic(err) + } +} +``` ## Contact