From f7ec6ee84fdcd5dac7707cee6fcde07f27988e08 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Tue, 2 Aug 2016 07:58:58 -0500 Subject: [PATCH] mailjet add/config --- Gemfile | 4 ++-- Gemfile.lock | 17 +++++++++++++++++ app/mailers/application_mailer.rb | 2 +- config/application.rb | 3 +++ config/application.yml.sample | 2 ++ config/initializers/mailjet.rb | 5 +++++ 6 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 config/initializers/mailjet.rb diff --git a/Gemfile b/Gemfile index 0f574db..b03c04f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,17 @@ source 'https://rubygems.org' gem 'figaro', '~> 1.1.1' -gem 'settingslogic', '~> 2.0.9' gem 'bcrypt', '~> 3.1.7' gem 'mysql2', '>= 0.3.18', '< 0.5' gem 'rails', '~> 5.0.0' -# gem 'autoprefixer-rails' gem 'jbuilder', '~> 2.6' gem 'jquery-rails' gem 'json', '~> 2.0.2' +gem 'mailjet', '~> 1.3.8' gem 'puma', '~> 3.0' gem 'sass-rails', '~> 5.0' +gem 'settingslogic', '~> 2.0.9' gem 'turbolinks', '~> 5' gem 'uglifier', '>= 1.3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 54d643d..22880a9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,6 +62,8 @@ GEM coderay (1.1.1) concurrent-ruby (1.0.2) debug_inspector (0.0.2) + domain_name (0.5.20160615) + unf (>= 0.0.5, < 1.0.0) em-websocket (0.5.1) eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) @@ -98,6 +100,8 @@ GEM guard-shell (0.7.1) guard (>= 2.0.0) guard-compat (~> 1.0) + http-cookie (1.0.2) + domain_name (~> 0.5) http_parser.rb (0.6.0) i18n (0.7.0) jbuilder (2.6.0) @@ -117,6 +121,10 @@ GEM lumberjack (1.0.10) mail (2.6.4) mime-types (>= 1.16, < 4) + mailjet (1.3.8) + activesupport (>= 3.1.0) + rack (>= 1.4.0) + rest-client method_source (0.8.2) mime-types (3.1) mime-types-data (~> 3.2015) @@ -134,6 +142,7 @@ GEM sass (>= 3.3) thor (~> 0.19) nenv (0.3.0) + netrc (0.11.0) nio4r (1.2.1) nokogiri (1.6.8) mini_portile2 (~> 2.1.0) @@ -193,6 +202,10 @@ GEM rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) + rest-client (2.0.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) rubocop (0.42.0) parser (>= 2.3.1.1, < 3.0) powerpack (~> 0.1) @@ -233,6 +246,9 @@ GEM thread_safe (~> 0.1) uglifier (3.0.0) execjs (>= 0.3.0, < 3) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.2) unicode-display_width (1.1.0) web-console (3.3.1) actionview (>= 5.0) @@ -264,6 +280,7 @@ DEPENDENCIES jquery-rails json (~> 2.0.2) listen (~> 3.0) + mailjet (~> 1.3.8) minitest-reporters mysql2 (>= 0.3.18, < 0.5) neat diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b223..e21ed33 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' + default from: ENV['default_mail_from'] layout 'mailer' end diff --git a/config/application.rb b/config/application.rb index 5b0cbe8..4bbbd91 100644 --- a/config/application.rb +++ b/config/application.rb @@ -20,5 +20,8 @@ module SkillAssessmentApp # bower config.assets.paths << Rails.root.join('vendor', 'assets', 'bower_components') + + config.action_mailer.delivery_method = :mailjet + config.action_mailer.default_url_options = { host: ENV['full_app_url'] } end end diff --git a/config/application.yml.sample b/config/application.yml.sample index 506166b..4c8f82f 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -7,6 +7,7 @@ defaults: &defaults mailjet_key: "api-key" mailjet_secret: "api-secret" default_mail_from: "skills-assessment@dev.perficientxd.com" + full_app_url: "localhost:3000" development: <<: *defaults @@ -19,3 +20,4 @@ production: mysql_usr: "user" mysql_pwd: "password!" secret_key_base: "super-long-secret-key-base" + full_app_url: "dev.perficientxd.com/Skills-Assessment/" diff --git a/config/initializers/mailjet.rb b/config/initializers/mailjet.rb new file mode 100644 index 0000000..2481ab2 --- /dev/null +++ b/config/initializers/mailjet.rb @@ -0,0 +1,5 @@ +Mailjet.configure do |config| + config.api_key = ENV['mailjet_key'] + config.secret_key = ENV['mailjet_secret'] + config.default_from = ENV['default_mail_from'] +end