Project

smtp2go

0.0
No release in over 3 years
Low commit activity in last 3 years
Interacts directly with smtp2go's API to facilitate sending of email.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 0.8.19
>= 2.13.0, ~> 2.13
>= 4.6.4, ~> 4.6
~> 12.0
~> 3.0
>= 3.0.3, ~> 3.0
>= 2.3.2, ~> 2.3

Runtime

~> 0.14.0
 Project Readme

Build Status Coverage Status Gem Version Dependency Status Code Climate Issue Count license

smtp2go

Library for interfacing with the smtp2go API

We also have a Ruby on Rails Library

Installation

Add this line to your application's Gemfile:

gem 'smtp2go'

And then execute:

$ bundle

Or install it yourself as:

$ gem install smtp2go

Usage

Sign up for a free account here and get an API key. At your shell, run:

$ export SMTP2GO_API_KEY="<your_API_key>"

Here is a REPL session showing a successful send and probing of the response object:

[1] pry(main)> require 'smtp2go'
=> true
[2] pry(main)> client = Smtp2go::Smtp2goClient.new
=> #<Smtp2go::Smtp2goClient:0x007fb6ee17b108
 @api_key="<redacted>",
 @headers=
  {"Content-Type"=>"application/json",
   "X-Smtp2go-Api"=>"smtp2go-ruby",
[3] pry(main)> payload = {
[3] pry(main)*>   sender: 'dave@example.com',
[3] pry(main)*>   recipients: ['matt@example.com'],
[3] pry(main)*>   subject: 'Test Message',
[3] pry(main)*>   text: 'Test message',
[3] pry(main)*>   html: '<html><body><h1>Test HTML message</h1></body></html>'}</html>'}
=> {:sender=>'dave@example.com',
 :recipients=>['matt@example.com'],
 :subject=>'Test Message',
 :text=>'Test message',
 :html=>'<html><body><h1>Test HTML message</h1></body></html>'}</html>'}
[4] pry(main)> response = client.send payload
=> #<Smtp2go::Smtp2goResponse:0x007fb6ee268840
 @rate_limit=
  #<Smtp2go::RateLimit:0x007fb6ee268818
   @limit="250",
   @remaining="250",
   @reset="51">,
 @response=
  {"request_id"=>"<redacted>",
   "data"=>{"failures"=>[], "succeeded"=>1, "failed"=>0}}>
[5] pry(main)> response.rate_limit
=> #<Smtp2go::RateLimit:0x007fb6ee268818
 @limit="250",
 @remaining="250",
 @reset="51">
[6] pry(main)> response.success?
=> true
[7] pry(main)> response.errors
=> nil
[8] pry(main)> response.json
=> {"request_id"=>"<redacted>",
 "data"=>{"failures"=>[], "succeeded"=>1, "failed"=>0}}
[9] pry(main)>

Full API documentation can be found here, with Ruby specific docs here

Development

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.

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/smtp2go-oss/smtp2go-ruby.

License

The gem is available as open source under the terms of the MIT License.