diff --git a/Gemfile b/Gemfile index 80b0658..c27da07 100644 --- a/Gemfile +++ b/Gemfile @@ -24,9 +24,11 @@ gem 'configatron' gem 'pry' gem 'rest-client' gem 'mail' +gem 'mandrill-api' gem 'gmail-britta', :git => 'git://github.com/bkrausz/gmail-britta.git', :ref => 'ced6355443fe2b99f6414b2da096c70a38b23f98' group :development, :test do gem 'mocha' + gem 'rerun' end diff --git a/Gemfile.lock b/Gemfile.lock index 1f55b54..6d9bc2e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,6 +27,8 @@ GEM bson_ext (1.11.1) bson (~> 1.11.1) builder (3.2.2) + celluloid (0.16.0) + timers (~> 4.0.0) chalk-config (0.2.1) configatron (~> 4.4) chalk-log (0.1.2) @@ -37,9 +39,11 @@ GEM configatron (4.4.1) einhorn (0.6.3) erubis (2.7.0) + excon (0.45.4) extlib (0.9.16) faraday (0.9.0) multipart-post (>= 1.2, < 3) + ffi (1.9.10) google-api-client (0.7.1) addressable (>= 2.3.2) autoparse (>= 0.3.3) @@ -52,11 +56,16 @@ GEM signet (>= 0.5.0) uuidtools (>= 2.1.0) haml (3.1.8) + hitimes (1.2.2) i18n (0.6.11) json (1.8.1) jwt (1.2.0) launchy (2.4.3) addressable (~> 2.3) + listen (2.10.1) + celluloid (~> 0.16.0) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) little-plugger (1.1.3) logging (1.8.2) little-plugger (>= 1.1.3) @@ -64,6 +73,9 @@ GEM lspace (0.13) mail (2.6.3) mime-types (>= 1.16, < 3) + mandrill-api (1.0.53) + excon (>= 0.16.0, < 1.0) + json (>= 1.7.7, < 2.0) metaclass (0.0.4) method_source (0.8.2) mime-types (2.4.3) @@ -96,6 +108,11 @@ GEM rack_csrf (2.5.0) rack (>= 1.1.0) rake (10.4.0) + rb-fsevent (0.9.6) + rb-inotify (0.9.5) + ffi (>= 0.5.0) + rerun (0.10.0) + listen (~> 2.7, >= 2.7.3) rest-client (1.7.2) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) @@ -113,6 +130,8 @@ GEM thread (0.1.4) thread_safe (0.3.4) tilt (1.4.1) + timers (4.0.4) + hitimes tzinfo (1.2.2) thread_safe (~> 0.1) uuidtools (2.1.5) @@ -130,6 +149,7 @@ DEPENDENCIES gmail-britta! google-api-client mail + mandrill-api mocha mongo_mapper pry @@ -137,6 +157,10 @@ DEPENDENCIES rack-flash3 rack_csrf rake + rerun rest-client sinatra thread + +BUNDLED WITH + 1.10.6 diff --git a/bin/test_mandrill.rb b/bin/test_mandrill.rb new file mode 100755 index 0000000..a201aec --- /dev/null +++ b/bin/test_mandrill.rb @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby +require File.expand_path('../lib/gaps', File.dirname(__FILE__)) + +Gaps.init + +Gaps::Email.send_email( + :to => configatron.notify.to, + :from => configatron.notify.from, + :subject => "[gaps] Testing email", + :body => <opts[:from], + "text"=>opts[:body], + "to"=> [{"email"=>opts[:to], + "type"=>"to"}], + "subject"=>opts[:subject], + } + async = false + result = mandrill.messages.send message + + rescue Mandrill::Error => e + # Mandrill errors are thrown as exceptions + log.error "A mandrill error occurred: #{e.class} - #{e.message}" + raise + end + else + mail.delivery_method :sendmail + mail.deliver! + end else log.info("Would have sent", email: mail.to_s) end diff --git a/site.yaml.sample b/site.yaml.sample index 7694ca5..d6d2abf 100644 --- a/site.yaml.sample +++ b/site.yaml.sample @@ -21,10 +21,14 @@ info: notify: # Whether to send an email notifying people when a new list is # created. If disabled, will instead just print the email to the - # console. (Note you must have a functioning sendmail setup for this - # to work; a TODO is to integrate with an email provider like - # Mailgun.) + # console. + # Can use sendmail or Mandrill to send emails send_email: false + # Default provider + provider: sendmail + # Mandrill - need to include and API key + #provider: mandrill + #api_key: xxxxxxxx # What email address to notify. to: all-bots@example.com # What email address to send from. In Stripe's email transparency