Module: AWS::SES

Defined in:
lib/aws/ses/base.rb,
lib/aws/ses/info.rb,
lib/aws/ses/version.rb,
lib/aws/ses/response.rb,
lib/aws/ses/addresses.rb,
lib/aws/ses/send_email.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: Info, SendEmail, VERSION Classes: Addresses, Base, DeleteVerifiedEmailAddressResponse, EmailResponse, GetSendQuotaResponse, GetSendStatisticsResponse, ListVerifiedEmailAddressesResponse, Response, ResponseError, SendEmailResponse, SendRawEmailResponse, VerifyEmailAddressResponse

Constant Summary collapse

API_VERSION =
'2010-12-01'
DEFAULT_HOST =
'email.us-east-1.amazonaws.com'
USER_AGENT =
'github-aws-ses-ruby-gem'
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



55
56
57
# File 'lib/aws/ses/base.rb', line 55

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.



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

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