amazon-ses 0.0.2 → 0.0.3
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 +51 -4
- data/lib/amazon-ses.rb +2 -2
- data/lib/amazon_authentication.rb +0 -4
- data/lib/amazon_deliver.rb +0 -5
- data/lib/amazon_email.rb +12 -9
- data/lib/amazon_url_generator.rb +0 -3
- metadata +5 -5
data/README
CHANGED
@@ -1,8 +1,55 @@
|
|
1
|
-
|
1
|
+
=amazon-ses
|
2
|
+
A gem for interfacing with Amazon's Simple Email Service
|
2
3
|
|
3
|
-
|
4
|
+
==Features:
|
5
|
+
Currently you can:
|
6
|
+
* Send a basic raw text email.
|
7
|
+
* Send email with a .erb template
|
4
8
|
|
5
|
-
e = AmazonEmail.new(options)
|
6
9
|
|
7
|
-
|
10
|
+
==Prerequisite
|
8
11
|
|
12
|
+
1. First, make sure you validate the email that you are going to use in the "from" section of the email.
|
13
|
+
|
14
|
+
http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/
|
15
|
+
|
16
|
+
==How does it work:
|
17
|
+
|
18
|
+
1. Build email:
|
19
|
+
|
20
|
+
* Raw email without a .erb template:
|
21
|
+
You can achieve this by NOT specifying a :template in your options:
|
22
|
+
|
23
|
+
options = {
|
24
|
+
:from => 'email@gmail.com',
|
25
|
+
:to => 'email@gmail.com',
|
26
|
+
:subject => 'Testing',
|
27
|
+
:body => 'THis is a test',
|
28
|
+
:aws_access_key => 'your acess key',
|
29
|
+
:aws_secret_key => 'your secret key'
|
30
|
+
}
|
31
|
+
|
32
|
+
e = AmazonEmail.new(options)
|
33
|
+
|
34
|
+
* Email that will use a .erb template:
|
35
|
+
You can achieve this by specifying the location of you .erb file in the :template option:
|
36
|
+
|
37
|
+
options_2 = {
|
38
|
+
:from => 'from@email.com',
|
39
|
+
:to => 'to@email.com',
|
40
|
+
:subject => 'This is the subject of the email',
|
41
|
+
:aws_access_key => "access_key_id",
|
42
|
+
:aws_secret_key => "secret_access_key",
|
43
|
+
:template => File.new("sample_email.erb").read
|
44
|
+
}
|
45
|
+
|
46
|
+
e = AmazonEmail.new(options_2)
|
47
|
+
|
48
|
+
2. Send it
|
49
|
+
|
50
|
+
e.send
|
51
|
+
|
52
|
+
|
53
|
+
== Install:
|
54
|
+
|
55
|
+
* sudo gem install amazon-ses
|
data/lib/amazon-ses.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'net/https'
|
3
3
|
require 'uri'
|
4
|
-
require 'rest-client'
|
5
4
|
require 'openssl'
|
6
5
|
require 'base64'
|
6
|
+
require 'erb'
|
7
7
|
require 'amazon_url_generator'
|
8
8
|
require 'amazon_authentication'
|
9
9
|
require 'amazon_deliver'
|
10
|
-
require 'amazon_email'
|
10
|
+
require 'amazon_email'
|
data/lib/amazon_deliver.rb
CHANGED
data/lib/amazon_email.rb
CHANGED
@@ -1,23 +1,26 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'amazon_url_generator'
|
3
|
-
require 'amazon_authentication'
|
4
|
-
require 'amazon_deliver'
|
5
|
-
|
6
1
|
class AmazonEmail
|
7
2
|
include AmazonDeliver
|
8
3
|
|
9
|
-
attr_accessor :from, :to, :subject, :body, :aws_access_key, :aws_secret_key
|
4
|
+
attr_accessor :from, :to, :subject, :body, :template, :aws_access_key, :aws_secret_key
|
10
5
|
|
11
6
|
def initialize(options)
|
12
7
|
@from = options[:from]
|
13
8
|
@to = options[:to]
|
14
|
-
@subject = options[:subject]
|
15
|
-
@body = options[:body]
|
9
|
+
@subject = options[:subject]
|
10
|
+
@body = options[:body]
|
11
|
+
@template = options[:template]
|
16
12
|
@aws_access_key = options[:aws_access_key] || ENV['AWS_ACCESS_KEY']
|
17
|
-
@aws_secret_key = options[:aws_secret_key] || ENV['AWS_SECRET_KEY']
|
13
|
+
@aws_secret_key = options[:aws_secret_key] || ENV['AWS_SECRET_KEY']
|
18
14
|
end
|
15
|
+
|
16
|
+
def get_binding
|
17
|
+
binding
|
18
|
+
end
|
19
19
|
|
20
20
|
def send
|
21
|
+
if self.template
|
22
|
+
self.body = ERB.new(self.template).result(self.get_binding)
|
23
|
+
end
|
21
24
|
AmazonDeliver.get(self)
|
22
25
|
end
|
23
26
|
|
data/lib/amazon_url_generator.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'uri'
|
3
|
-
|
4
1
|
module AmazonUrlGenerator
|
5
2
|
def self.create_query(from, to, subject, body)
|
6
3
|
"/?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}]"))}"
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon-ses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
- Guille
|
13
|
+
- Guille Carlos
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-02-05 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|