Skip to content

davidbanham/notifications

Repository files navigation

Notifications

PkgGoDev

Notifications is a util to send emails via Amazon SES.

Notifications supports:

  • HTML bodies
  • Text bodies
  • Emails with only an HTML or Text body
  • Attachments
  • JSON serialisation of emails and attachments
  • Emails sent to an icloud address and read via the Mail app on iOS (harder than you think!)

Notifications does not support:

  • Inline attachments

Example

package main

import (
	"log"
	"strings"

	"github.com/davidbanham/notifications"
)

func main() {
	if err := notifications.SendEmail(notifications.Email{
		To:      "[email protected]",
		From:    "[email protected]",
		ReplyTo: "[email protected]", //optional
		Text:    "this is the text part of a test run",
		HTML:    "this <i>is the HTML part of a test</i> run",
		Subject: "Simple Test Run",
		Attachments: []notifications.Attachment{
			notifications.Attachment{
				ContentType: "text/plain",
				Filename:    "test_data.txt",
				Data:        strings.NewReader("oh hi I am an attachment"),
			},
		},
	}); err != nil {
		log.Fatal(err)
	}
}