ses

package module
v0.0.0-...-6bd8d17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2016 License: MIT Imports: 12 Imported by: 8

README

go-ses - send email using Amazon AWS Simple Email Service

xrefs funcs top func library users status

go-ses is an API client library for Amazon AWS Simple Email Service (SES). It is a fork of Patrick Crosby's stathat/amzses.

Note: the public API is experimental and subject to change until further notice.

Usage

Documentation: go-ses on Sourcegraph.

Example: example_test.go (Sourcegraph):

package ses_test

import (
	"fmt"
	"github.com/sourcegraph/go-ses"
)

func Example() {
	// Change the From address to a sender address that is verified in your Amazon SES account.
	from := "notify@sourcegraph.com"
	to := "success@simulator.amazonses.com"

	// EnvConfig uses the AWS credentials in the environment variables $AWS_ACCESS_KEY_ID and
	// $AWS_SECRET_KEY.
	res, err := ses.EnvConfig.SendEmail(from, to, "Hello, world!", "Here is the message body.")
	if err == nil {
		fmt.Printf("Sent email: %s...\n", res[:32])
	} else {
		fmt.Printf("Error sending email: %s\n", err)
	}

	// output:
	// Sent email: <SendEmailResponse xmlns="http:/...
}

Running tests

  1. Set the environment variables $AWS_ACCESS_KEY_ID and $AWS_SECRET_KEY and $AWS_SES_ENDPOINT.
  2. Example SES Endpoint https://email.us-west-2.amazonaws.com
  3. Run go test -from=user@example.com, where user@example.com is a sender address that is verified in your Amazon SES account.

Contributors

Changelog

2013-06-11 (forked from stathat/amzses)

  • renamed API functions to be consistent with AWS SES API endpoints
  • reads AWS credentials from a Config struct, not from a config file
  • added runnable example_test.go

Documentation

Overview

Package ses sends emails using the Amazon AWS Simple Email Service (SES).

Example
// Change the From address to a sender address that is verified in your Amazon SES account.
from := "notify@sourcegraph.com"
to := "success@simulator.amazonses.com"

// EnvConfig uses the AWS credentials in the environment variables $AWS_ACCESS_KEY_ID and
// $AWS_SECRET_KEY.
res, err := ses.EnvConfig.SendEmail(from, to, "Hello, world!", "Here is the message body.")
if err == nil {
	fmt.Printf("Sent email: %s...\n", res[:32])
} else {
	fmt.Printf("Error sending email: %s\n", err)
}
Output:

Sent email: <SendEmailResponse xmlns="http:/...

Index

Examples

Constants

This section is empty.

Variables

View Source
var EnvConfig = Config{
	Endpoint:        os.Getenv("AWS_SES_ENDPOINT"),
	AccessKeyID:     os.Getenv("AWS_ACCESS_KEY_ID"),
	SecretAccessKey: os.Getenv("AWS_SECRET_KEY"),
}

EnvConfig takes the access key ID and secret access key values from the environment variables $AWS_ACCESS_KEY_ID and $AWS_SECRET_KEY, respectively.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Endpoint is the AWS endpoint to use for requests.
	Endpoint string

	// AccessKeyID is your Amazon AWS access key ID.
	AccessKeyID string

	// SecretAccessKey is your Amazon AWS secret key.
	SecretAccessKey string
}

Config specifies configuration options and credentials for accessing Amazon SES.

func (*Config) SendEmail

func (c *Config) SendEmail(from, to, subject, body string) (string, error)

SendEmail sends a plain text email. Note that from must be a verified address in the AWS control panel.

func (*Config) SendEmailHTML

func (c *Config) SendEmailHTML(from, to, subject, bodyText, bodyHTML string) (string, error)

SendEmailHTML sends a HTML email. Note that from must be a verified address in the AWS control panel.

func (*Config) SendRawEmail

func (c *Config) SendRawEmail(raw []byte) (string, error)

SendRawEmail sends a raw email. Note that from must be a verified address in the AWS control panel.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL