metamailer 1.0.1 → 1.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/lib/core.rb +14 -0
- data/lib/elasticemail.rb +17 -0
- data/lib/mailgun.rb +23 -0
- data/lib/postageapp.rb +22 -0
- metadata +5 -1
data/lib/core.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
class MetaMailer
|
2
|
+
def send_secure uri, p
|
3
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
4
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
5
|
+
http.use_ssl = true
|
6
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
7
|
+
request.set_form_data(p)
|
8
|
+
response = http.request(request)
|
9
|
+
end
|
10
|
+
|
11
|
+
def send(from, to, subject, html, text)
|
12
|
+
false
|
13
|
+
end
|
14
|
+
end
|
data/lib/elasticemail.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class ElasticemailMailer < MetaMailer
|
2
|
+
attr_accessor :username
|
3
|
+
attr_accessor :api_key
|
4
|
+
|
5
|
+
def initialize(username, api_key)
|
6
|
+
@username = username
|
7
|
+
@api_key = api_key
|
8
|
+
end
|
9
|
+
|
10
|
+
def send(from, to, subject, html, text)
|
11
|
+
from_address = from.split("<")[1].split(">")[0]
|
12
|
+
from_name = from.split(" <")[0]
|
13
|
+
uri = URI("https://api.elasticemail.com/mailer/send")
|
14
|
+
p = {:username => self.username, :api_key => self.api_key, :from => from_address, :from_name => from_name, :to => to, :subject => subject, :body_html => html, :body_text => text}
|
15
|
+
response = send_secure(uri, p)
|
16
|
+
end
|
17
|
+
end
|
data/lib/mailgun.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "multimap"
|
2
|
+
require "rest-client"
|
3
|
+
|
4
|
+
class Mailgun < MetaMailer
|
5
|
+
attr_accessor :username
|
6
|
+
attr_accessor :api_key
|
7
|
+
|
8
|
+
def initialize(username, api_key)
|
9
|
+
@username = username
|
10
|
+
@api_key = api_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def send(from, to, subject, html, text)
|
14
|
+
data = Multimap.new
|
15
|
+
data[:from] = from
|
16
|
+
data[:to] = to
|
17
|
+
data[:subject] = subject
|
18
|
+
data[:text] = text
|
19
|
+
data[:html] = html
|
20
|
+
RestClient.post "https://api:#{@api_key}"\
|
21
|
+
"@api.mailgun.net/v2/#{@username}.mailgun.org/messages", data
|
22
|
+
end
|
23
|
+
end
|
data/lib/postageapp.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'postageapp'
|
2
|
+
|
3
|
+
PostageApp.configure do |config|
|
4
|
+
config.api_key = ""# api key goes here
|
5
|
+
end
|
6
|
+
|
7
|
+
class PostageAppMailer < MetaMailer
|
8
|
+
def send(from, to, subject, html, text)
|
9
|
+
request = PostageApp::Request.new(:send_message, {
|
10
|
+
'headers' => {
|
11
|
+
'from' => from,
|
12
|
+
'subject' => subject,
|
13
|
+
},
|
14
|
+
'recipients' => to,
|
15
|
+
'content' => {
|
16
|
+
'text/plain' => text
|
17
|
+
}
|
18
|
+
})
|
19
|
+
response = request.send
|
20
|
+
response.ok?
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metamailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -19,6 +19,10 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- lib/metamailer.rb
|
22
|
+
- lib/core.rb
|
23
|
+
- lib/mailgun.rb
|
24
|
+
- lib/elasticemail.rb
|
25
|
+
- lib/postageapp.rb
|
22
26
|
homepage: http://github.com/brg8/metamailer
|
23
27
|
licenses:
|
24
28
|
- GNU
|