func ExampleClient() { c := postmark.Client{ ApiKey: "YOUR-API-KEY", Secure: true, } res, err := c.Send(&postmark.Message{ From: &mail.Address{ Name: "SENDER-NAME", Address: "SENDER-EMAIL", }, To: []*mail.Address{ { Name: "RECIPIENT NAME", Address: "RECIPIENT EMAIL", }, }, Subject: "SUBJECT", TextBody: strings.NewReader("MESSAGE-BODY-AS-TEXT"), }) if err != nil { panic(err) } fmt.Printf("%#v\n", res) }
func sendViaPostmark(subject string, body string) { client := postmark.Client{ ApiKey: os.Getenv("POSTMARK_API_KEY"), Secure: true, } html := strings.NewReader(body) res, err := client.Send(&postmark.Message{ From: &mail.Address{ Name: os.Getenv("FROM_NAME"), Address: os.Getenv("FROM_EMAIL"), }, To: []*mail.Address{ { Name: os.Getenv("TO_NAME"), Address: os.Getenv("TO_EMAIL"), }, }, Subject: subject, HtmlBody: html, }) if err != nil { log.Print("postmark errors") log.Print(err) } if res != nil { log.Print("postmark success") log.Print(res) } }