amazon_ses 0.1.0 → 0.2.0
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/Rakefile +1 -0
- data/VERSION +1 -1
- data/amazon_ses.gemspec +5 -2
- data/lib/amazon_ses.rb +1 -0
- data/lib/amazon_ses/amz_mail.rb +19 -13
- data/lib/amazon_ses/stats.rb +14 -0
- data/test/test_amazon_ses.rb +12 -7
- metadata +15 -3
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/johnnyiller/amazon_ses"
|
12
12
|
gem.authors = ["jeff durand"]
|
13
13
|
gem.add_dependency "mail"
|
14
|
+
gem.add_dependency "xml-simple"
|
14
15
|
#gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
15
16
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
17
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/amazon_ses.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{amazon_ses}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["jeff durand"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-19}
|
13
13
|
s.description = %q{wrapper for the simple email service api}
|
14
14
|
s.email = %q{jeff.durand@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -49,11 +49,14 @@ Gem::Specification.new do |s|
|
|
49
49
|
|
50
50
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
51
51
|
s.add_runtime_dependency(%q<mail>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
|
52
53
|
else
|
53
54
|
s.add_dependency(%q<mail>, [">= 0"])
|
55
|
+
s.add_dependency(%q<xml-simple>, [">= 0"])
|
54
56
|
end
|
55
57
|
else
|
56
58
|
s.add_dependency(%q<mail>, [">= 0"])
|
59
|
+
s.add_dependency(%q<xml-simple>, [">= 0"])
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
data/lib/amazon_ses.rb
CHANGED
data/lib/amazon_ses/amz_mail.rb
CHANGED
@@ -9,20 +9,26 @@ module AmazonSES
|
|
9
9
|
"Message.Subject.Data"=>subject,
|
10
10
|
"Message.Body.Text.Data"=>body},secret,key)
|
11
11
|
end
|
12
|
+
# This will construct and send a raw email message will send unless
|
13
|
+
# quota is reached. If quota is reached it will raise an exception.
|
14
|
+
# It takes two api calls to send an email....
|
12
15
|
def self.send_html(source,to_addresses,subject_txt,body_txt,secret,key)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
if AmazonSES::StatObject.new(secret,key).reached_quota?
|
17
|
+
raise "Sorry you have reached your quota."
|
18
|
+
else
|
19
|
+
mail = Mail.new do
|
20
|
+
to to_addresses
|
21
|
+
from source
|
22
|
+
subject subject_txt
|
23
|
+
html_part do
|
24
|
+
content_type 'text/html; charset=UTF-8'
|
25
|
+
body body_txt
|
26
|
+
end
|
27
|
+
end
|
28
|
+
str=mail.to_s.gsub("multipart/alternative","multipart/mixed")
|
29
|
+
encoded = Base64.encode64(str)
|
30
|
+
AmazonSES::Base.make_request({"Action"=>"SendRawEmail", "RawMessage.Data"=>encoded},secret,key)
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
data/lib/amazon_ses/stats.rb
CHANGED
@@ -8,5 +8,19 @@ module AmazonSES
|
|
8
8
|
AmazonSES::Base.make_request({"Action"=>"GetSendStatistics"},secret,key)
|
9
9
|
end
|
10
10
|
end
|
11
|
+
class StatObject
|
12
|
+
attr_accessor :sent_last_24_hours, :max_send_rate, :max_24_hour_send
|
13
|
+
|
14
|
+
def initialize(secret,key)
|
15
|
+
resp = Stats.send_quota(secret,key)
|
16
|
+
hash = XmlSimple.xml_in(resp.body)
|
17
|
+
@sent_last_24_hours = hash["GetSendQuotaResult"][0]["SentLast24Hours"][0].to_i
|
18
|
+
@max_send_rate = hash["GetSendQuotaResult"][0]["MaxSendRate"][0].to_i
|
19
|
+
@max_24_hour_send = hash["GetSendQuotaResult"][0]["Max24HourSend"][0].to_i
|
20
|
+
end
|
21
|
+
def reached_quota?
|
22
|
+
@sent_last_24_hours >= @max_24_hour_send
|
23
|
+
end
|
24
|
+
end
|
11
25
|
|
12
26
|
end
|
data/test/test_amazon_ses.rb
CHANGED
@@ -8,13 +8,18 @@ class TestAmazonSes < Test::Unit::TestCase
|
|
8
8
|
#should "Be able to verify address" do
|
9
9
|
# resp = AmazonSES::Verify.address("admin@flickaday.com",@aws_secret,@aws_key)
|
10
10
|
#end
|
11
|
-
should "Get some stats" do
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
should "Send an email" do
|
16
|
-
|
17
|
-
|
11
|
+
#should "Get some stats" do
|
12
|
+
# resp = AmazonSES::Stats.send_quota(@aws_secret,@aws_key)
|
13
|
+
# puts resp.body
|
14
|
+
#end
|
15
|
+
#should "Send an email" do
|
16
|
+
# resp = AmazonSES::AmzMail.send_html("admin@flickaday.com","admin@flickaday.com","hey how are you doing","<h1>Just wanted</h1><p> to send you a quick message.</p>",@aws_secret,@aws_key)
|
17
|
+
# puts resp.body
|
18
|
+
#end
|
19
|
+
#should ""
|
20
|
+
should "not be at quota" do
|
21
|
+
statobj = AmazonSES::StatObject.new(@aws_secret,@aws_key)
|
22
|
+
assert !statobj.reached_quota?
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- jeff durand
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-19 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -29,6 +29,18 @@ dependencies:
|
|
29
29
|
version: "0"
|
30
30
|
type: :runtime
|
31
31
|
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: xml-simple
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
32
44
|
description: wrapper for the simple email service api
|
33
45
|
email: jeff.durand@gmail.com
|
34
46
|
executables: []
|