smtp2go 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/Gemfile +3 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/smtp2go.rb +4 -0
- data/lib/smtp2go/core.rb +76 -0
- data/lib/smtp2go/exceptions.rb +4 -0
- data/lib/smtp2go/settings.rb +12 -0
- data/lib/smtp2go/version.rb +3 -0
- data/smtp2go.gemspec +41 -0
- metadata +197 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4155068c14c95b7f38616a5c2b45742957755a01
|
4
|
+
data.tar.gz: 71dca8df7287bf32c467969bd2ac419d1a193d9e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9812d58cf9c8a20530efc2a40d1654fa47c02d67f7b803e702863e91c8c01738b9eed5fc848f779d72eb6561d8c4d0a4bdb810b0dc1a213f941dfb54748c64ff
|
7
|
+
data.tar.gz: 4915f1df675785fa8ef538d53c186dc0a059f4de601ac0ab20592dc1cd30f3dba8f324a534112b7130c4b1ee2c476443413d6eacb9816d715d8505003a02e53d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.1
|
5
|
+
before_install: gem install bundler -v 1.13.7
|
6
|
+
notifications:
|
7
|
+
slack:
|
8
|
+
template:
|
9
|
+
- "Build status: 👻%{result}👻 in %{duration} "
|
10
|
+
- "<%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}>) of %{repository}@%{branch} by %{author}"
|
11
|
+
secure: VukzX7mAGmtiPlKGVk2HUy2lcs/ukgLcg5/PZv4KPgmckmjxhPcho2b3j0vpO/soMuLxStUwsUSqqp0SW8lZrkn43Szb9ijHtQLYVi9ADAXegiC6O6p/uelhzqyu+OVvGqRMrTfUPhhNCWbis6RSQEZcROJPMBQLgPF0MuPXAwWV12eL8u/0LsfT0EP9m8rle7bRPexBiDNJiNJj9M3GZz/ZNpBakRLjEUH6OBiG6dTXQx2W6jizKf+/Nu3MH52FydJIXvwzpFiiTLz7GRW3BCyL0hCTw7ya/IOr/4Fh416hQ6cNRyIsPyzmBZYILuJVQdhMjRdIfr29yUPgms3aWYx5uQ2GwgZ6FRvdnLrtOHXcDmUgj/r2IB9K7aVtQnS0BXzS3e745BgyufwH3/lJsebZ2KbMtBN3utcinSn2uAgTPVGUQlrxvOPp5jac7zisdIQwrNBoVY/pipybp/jzG/6be5lLBxTQM9UmXoZSXfy4D4Rfcr+w6eZqbbTYJ0EJmPFc+b1rDVaqxS1BTTYWq4dJVL6hAMR4Gb9wSM+iFQi536S49P/+ZuVvw4WtG4+i2eFkfFZzbt82pVRClYr8Ip8RJ8oQrpGb0N9CsRG5PrQLch6mNR+/njMkZfFTYqyWjVpg73g8TMSzg871tG7jESgOs2rAEBSbW+adfAvQixo=
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 smtp2go
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Smtp2go
|
2
|
+
|
3
|
+
Library for interfacing with the [https://apidoc.smtp2go.com/documentation/#/README](SMTP2Go API)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'smtp2go'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install smtp2go
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Sign up for a free account [here](https://www.smtp2go.com/pricing) and get an API key. At your shell, run:
|
24
|
+
|
25
|
+
$ export SMTP2GO_API_KEY="<your_API_key>"
|
26
|
+
|
27
|
+
Then sending mail is as simple as:
|
28
|
+
|
29
|
+
require 'smtp2go'
|
30
|
+
|
31
|
+
smtp2go_client = Smtp2go::Smtp2goClient.new
|
32
|
+
|
33
|
+
payload = {
|
34
|
+
:sender=>"dave@example.com",
|
35
|
+
:recipients=>["matt@example.com"],
|
36
|
+
:subject=>"Trying out smtp2go!",
|
37
|
+
:message=>"Test Message"
|
38
|
+
}
|
39
|
+
|
40
|
+
response = smtp2go_client.send(payload)
|
41
|
+
|
42
|
+
Full API documentation can be found [here](https://apidoc.smtp2go.com/documentation/#/README)
|
43
|
+
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/smtp2go-oss/smtp2go.
|
54
|
+
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "smtp2go"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/smtp2go.rb
ADDED
data/lib/smtp2go/core.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'httparty'
|
3
|
+
require 'smtp2go/exceptions'
|
4
|
+
require 'smtp2go/settings'
|
5
|
+
|
6
|
+
module Smtp2go
|
7
|
+
# Ruby Library for interacting with the smtp2go API
|
8
|
+
|
9
|
+
class Smtp2goClient
|
10
|
+
attr_reader :headers, :send_endpoint
|
11
|
+
def initialize
|
12
|
+
@api_key = ENV['SMTP2GO_API_KEY']
|
13
|
+
@headers = HEADERS
|
14
|
+
@send_endpoint = SEND_ENDPOINT
|
15
|
+
raise Smtp2goAPIKeyException,
|
16
|
+
'smtp2go requires SMTP2GO_API_KEY Environment Variable to be set' if not @api_key
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param sender [String] the from email address
|
20
|
+
# @param recipients [Array <String>] the recipient email addresses
|
21
|
+
# @param subject [String] the email subject
|
22
|
+
# @param body [String] the email body
|
23
|
+
# @return [Smtp2goResponse] response object
|
24
|
+
def send(sender:, recipients:, subject:, message:)
|
25
|
+
payload = {
|
26
|
+
'api_key' => @api_key,
|
27
|
+
'sender' => sender,
|
28
|
+
'to' => recipients,
|
29
|
+
'subject' => subject,
|
30
|
+
'text_body' => message,
|
31
|
+
}
|
32
|
+
response = HTTParty.post(
|
33
|
+
@send_endpoint,
|
34
|
+
:body => JSON.dump(payload),
|
35
|
+
:headers => @headers)
|
36
|
+
return Smtp2goResponse.new response
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Smtp2goResponse
|
41
|
+
attr_reader :rate_limit
|
42
|
+
def initialize response
|
43
|
+
@response = response
|
44
|
+
@rate_limit = RateLimit.new @response.headers
|
45
|
+
end
|
46
|
+
|
47
|
+
def json
|
48
|
+
JSON.parse @response.body
|
49
|
+
end
|
50
|
+
|
51
|
+
def success?
|
52
|
+
self.json['data']['succeeded'] ? true : false
|
53
|
+
end
|
54
|
+
|
55
|
+
def errors
|
56
|
+
self.json['data']['error']
|
57
|
+
end
|
58
|
+
|
59
|
+
def request_id
|
60
|
+
self.json['request_id']
|
61
|
+
end
|
62
|
+
|
63
|
+
def status_code
|
64
|
+
@response.code
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class RateLimit
|
69
|
+
attr_reader :limit, :remaining, :reset
|
70
|
+
def initialize headers
|
71
|
+
@limit = headers['x-ratelimit-limit']
|
72
|
+
@remaining = headers['x-ratelimit-remaining']
|
73
|
+
@reset = headers['x-ratelimit-reset']
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'smtp2go/version'
|
2
|
+
|
3
|
+
module Smtp2go
|
4
|
+
API_ROOT = 'https://api.smtp2go.com/v3/'
|
5
|
+
API_SEND_URL = 'email/send'
|
6
|
+
SEND_ENDPOINT = API_ROOT + API_SEND_URL
|
7
|
+
HEADERS = {
|
8
|
+
'Content-Type' => 'application/json',
|
9
|
+
'X-Smtp2go-Api' => 'smtp2go-ruby',
|
10
|
+
'X-Smtp2go-Api-Version' => VERSION,
|
11
|
+
}
|
12
|
+
end
|
data/smtp2go.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'smtp2go/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "smtp2go"
|
8
|
+
spec.version = Smtp2go::VERSION
|
9
|
+
spec.authors = ["smtp2go"]
|
10
|
+
spec.email = ["devs@smtp2go.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Library for interfacing with smtp2go API}
|
13
|
+
spec.description = %q{Interacts directly with smtp2go's API to facilitate sending of email.}
|
14
|
+
spec.homepage = "https://github.com/smtp2go-oss/smtp2go-ruby.git"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
34
|
+
spec.add_development_dependency 'guard', '~> 2.13', '>= 2.13.0'
|
35
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.6', '>= 4.6.4'
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.3'
|
39
|
+
spec.add_development_dependency 'webmock', '~> 2.3', '>= 2.3.2'
|
40
|
+
spec.add_runtime_dependency "httparty", "~> 0.14.0"
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smtp2go
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- smtp2go
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.13'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.13.0
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.13'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.13.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: guard-rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '4.6'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 4.6.4
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '4.6'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 4.6.4
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '10.0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '10.0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '3.0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '3.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: vcr
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.0'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 3.0.3
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '3.0'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 3.0.3
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: webmock
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '2.3'
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.3.2
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.3'
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 2.3.2
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: httparty
|
137
|
+
requirement: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 0.14.0
|
142
|
+
type: :runtime
|
143
|
+
prerelease: false
|
144
|
+
version_requirements: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - "~>"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 0.14.0
|
149
|
+
description: Interacts directly with smtp2go's API to facilitate sending of email.
|
150
|
+
email:
|
151
|
+
- devs@smtp2go.com
|
152
|
+
executables: []
|
153
|
+
extensions: []
|
154
|
+
extra_rdoc_files: []
|
155
|
+
files:
|
156
|
+
- ".gitignore"
|
157
|
+
- ".rspec"
|
158
|
+
- ".travis.yml"
|
159
|
+
- Gemfile
|
160
|
+
- Guardfile
|
161
|
+
- LICENSE.txt
|
162
|
+
- README.md
|
163
|
+
- Rakefile
|
164
|
+
- bin/console
|
165
|
+
- bin/setup
|
166
|
+
- lib/smtp2go.rb
|
167
|
+
- lib/smtp2go/core.rb
|
168
|
+
- lib/smtp2go/exceptions.rb
|
169
|
+
- lib/smtp2go/settings.rb
|
170
|
+
- lib/smtp2go/version.rb
|
171
|
+
- smtp2go.gemspec
|
172
|
+
homepage: https://github.com/smtp2go-oss/smtp2go-ruby.git
|
173
|
+
licenses:
|
174
|
+
- MIT
|
175
|
+
metadata:
|
176
|
+
allowed_push_host: https://rubygems.org
|
177
|
+
post_install_message:
|
178
|
+
rdoc_options: []
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
requirements: []
|
192
|
+
rubyforge_project:
|
193
|
+
rubygems_version: 2.5.1
|
194
|
+
signing_key:
|
195
|
+
specification_version: 4
|
196
|
+
summary: Library for interfacing with smtp2go API
|
197
|
+
test_files: []
|