amazon-ses 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +8 -0
- data/lib/amazon-ses.rb +10 -0
- data/lib/amazon_authentication.rb +13 -0
- data/lib/amazon_deliver.rb +26 -0
- data/lib/amazon_email.rb +24 -0
- data/lib/amazon_url_generator.rb +8 -0
- metadata +72 -0
data/README
ADDED
data/lib/amazon-ses.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'openssl'
|
3
|
+
require 'base64'
|
4
|
+
|
5
|
+
module AmazonAuthentication
|
6
|
+
DIGEST = OpenSSL::Digest::Digest.new('sha1')
|
7
|
+
|
8
|
+
def self.key(aws_private, date)
|
9
|
+
hmac = OpenSSL::HMAC.digest(DIGEST, aws_private, date.to_s)
|
10
|
+
b64 = Base64.b64encode(hmac)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'net/https'
|
3
|
+
require 'amazon_authentication'
|
4
|
+
require 'amazon_url_generator'
|
5
|
+
|
6
|
+
module AmazonDeliver
|
7
|
+
|
8
|
+
def self.get(amazon_email)
|
9
|
+
resource = AmazonUrlGenerator.create_query(amazon_email.from, amazon_email.to, amazon_email.subject, amazon_email.body)
|
10
|
+
|
11
|
+
date = Time.new.localtime.strftime("%a, %d %b %Y %H:%M:%S %Z")
|
12
|
+
http = Net::HTTP.new("email.us-east-1.amazonaws.com", 443)
|
13
|
+
http.use_ssl = true
|
14
|
+
headers = {
|
15
|
+
'Date' => date.to_s,
|
16
|
+
'x-Amzn-Authorization' => "AWS3-HTTPS AWSAccessKeyId=#{amazon_email.aws_access_key}, Algorithm=HmacSHA1, Signature=#{AmazonAuthentication.key(amazon_email.aws_secret_key, date)}"
|
17
|
+
}
|
18
|
+
|
19
|
+
http.start do |http|
|
20
|
+
req = Net::HTTP::Get.new(resource, headers)
|
21
|
+
response = http.request(req)
|
22
|
+
resp = response.body
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/amazon_email.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'amazon_url_generator'
|
3
|
+
require 'amazon_authentication'
|
4
|
+
require 'amazon_deliver'
|
5
|
+
|
6
|
+
class AmazonEmail
|
7
|
+
include AmazonDeliver
|
8
|
+
|
9
|
+
attr_accessor :from, :to, :subject, :body, :aws_access_key, :aws_secret_key
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
@from = options[:from]
|
13
|
+
@to = options[:to]
|
14
|
+
@subject = options[:subject] || "Hello"
|
15
|
+
@body = options[:body] || "I don't know why someone would send you a empty email but they did"
|
16
|
+
@aws_access_key = options[:aws_access_key] || ENV['AWS_ACCESS_KEY']
|
17
|
+
@aws_secret_key = options[:aws_secret_key] || ENV['AWS_SECRET_KEY']
|
18
|
+
end
|
19
|
+
|
20
|
+
def send
|
21
|
+
AmazonDeliver.get(self)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module AmazonUrlGenerator
|
5
|
+
def self.create_query(from, to, subject, body)
|
6
|
+
"/?Action=SendEmail&Source=#{URI.escape(from, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}&Destination.ToAddresses.member.1=#{URI.escape(to, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}&Message.Subject.Data=#{URI.escape(subject, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}&Message.Body.Text.Data=#{URI.escape(body, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}"
|
7
|
+
end
|
8
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: amazon-ses
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Guille Carloss
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-26 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: A easy way to interact with Amazon SES.
|
23
|
+
email: gcarlos1@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- README
|
32
|
+
- lib/amazon_authentication.rb
|
33
|
+
- lib/amazon_deliver.rb
|
34
|
+
- lib/amazon_email.rb
|
35
|
+
- lib/amazon_url_generator.rb
|
36
|
+
- lib/amazon-ses.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://github.com/guillec/amazon-ses/
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
hash: 3
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.3.7
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Send a email with Amazon SES.
|
71
|
+
test_files: []
|
72
|
+
|