Module: AWS::SES

Defined in:
lib/aws/ses/base.rb,
lib/aws/ses/version.rb,
lib/aws/ses/response.rb,
lib/aws/ses/addresses.rb

Overview

AWS::SES is a Ruby library for Amazon's Simple Email Service's REST API (aws.amazon.com/ses).

Getting started

To get started you need to require 'aws/ses':

% irb -rubygems
irb(main):001:0> require 'aws/ses'
# => true

Before you can do anything, you must establish a connection using Base.new. A basic connection would look something like this:

ses = AWS::SES::Base.new(
  :access_key_id     => 'abc', 
  :secret_access_key => '123'
)

The minimum connection options that you must specify are your access key id and your secret access key.

Defined Under Namespace

Modules: VERSION Classes: Addresses, Base, DeleteVerifiedEmailAddressResponse, Error, ListVerifiedEmailAddressesResponse, Response, VerifyEmailAddressResponse

Constant Summary collapse

API_VERSION =
'2010-12-01'
DEFAULT_HOST =
'email.us-east-1.amazonaws.com'
Version =
[VERSION::MAJOR, VERSION::MINOR, VERSION::TINY, VERSION::BETA].compact * '.'

Class Method Summary collapse

Class Method Details

.authorization_header(key, alg, sig) ⇒ Object

Generates the HTTP Header String that Amazon looks for

Parameters:

  • key (String)

    the AWS Access Key ID

  • alg (String)

    the algorithm used for the signature

  • sig (String)

    the signature itself


53
54
55
# File 'lib/aws/ses/base.rb', line 53

def SES.authorization_header(key, alg, sig)
  "AWS3-HTTPS AWSAccessKeyId=#{key}, Algorithm=#{alg}, Signature=#{sig}"
end

.encode(secret_access_key, str, urlencode = true) ⇒ String

Encodes the given string with the secret_access_key by taking the hmac-sha1 sum, and then base64 encoding it. Optionally, it will also url encode the result of that to protect the string if it's going to be used as a query string parameter.

Parameters:

  • secret_access_key (String)

    the user's secret access key for signing.

  • str (String)

    the string to be hashed and encoded.

  • urlencode (Boolean) (defaults to: true)

    whether or not to url encode the result., true or false

Returns:

  • (String)

    the signed and encoded string.


35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/aws/ses/base.rb', line 35

def SES.encode(secret_access_key, str, urlencode=true)
  digest = OpenSSL::Digest::Digest.new('sha256')
  b64_hmac =
    Base64.encode64(
      OpenSSL::HMAC.digest(digest, secret_access_key, str)).gsub("\n","")

  if urlencode
    return CGI::escape(b64_hmac)
  else
    return b64_hmac
  end
end